- added function to get background sample from alpha markings
git-svn-id: http://moon:8086/svn/matlab/trunk@146 801c6759-fa7c-4059-a304-17956f83a07c
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 567 KiB |
@@ -23,25 +23,23 @@
|
||||
## Author: Jens <jens@orion>
|
||||
## Created: 2020-10-03
|
||||
|
||||
function chromakey (img_name)
|
||||
im = im2double(imread(img_name));
|
||||
im_rgb = imresize(im, 1);
|
||||
se = strel('square',3)
|
||||
# chromakey('adventure_rose', 20, 10)
|
||||
# chromakey('cineon_before', 200, 100)
|
||||
|
||||
#ref = [0.3 0.4 0.65]; # cineon_before
|
||||
ref = [0.2 0.6 0.95]; # adventure_rose
|
||||
|
||||
ref_rgb = toRef(ref, size(im_rgb));
|
||||
function chromakey (prj_name, k_e_matte, k_e_edge)
|
||||
|
||||
k_ds_matte = 1.0;
|
||||
k_e_matte = 20.0
|
||||
k_e_edge = 10.0
|
||||
|
||||
[im_rgb, ref_rgb] = prj_load(prj_name);
|
||||
|
||||
close all;
|
||||
|
||||
figure;
|
||||
matte = supermatte(im_rgb, ref_rgb, k_e_matte);
|
||||
[matte, dev, conf] = supermatte(im_rgb, ref_rgb, k_e_matte);
|
||||
imshow(matte); title("matte")
|
||||
figure;
|
||||
imshow(dev); title("dev")
|
||||
figure;
|
||||
imshow(conf); title("conf")
|
||||
|
||||
figure;
|
||||
intermediate = im_rgb.*matte;
|
||||
@@ -60,10 +58,6 @@ imwrite(edges, 'edges.png','png');
|
||||
imwrite(final, 'final.png','png','alpha', matte);
|
||||
imwrite(matte, 'alpha.png','png');
|
||||
|
||||
function r = toRef(ref, d)
|
||||
r = repmat(reshape(ref,1, 1, 3), d(1), d(2));
|
||||
endfunction
|
||||
|
||||
function mask = mask_clip_above(mask_in, thresh)
|
||||
k = mask_in < thresh;
|
||||
mask = k .* mask_in + kn;
|
||||
|
||||
|
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 658 KiB |
|
Before Width: | Height: | Size: 927 KiB After Width: | Height: | Size: 4.3 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 5.4 MiB |
@@ -23,10 +23,17 @@
|
||||
## Author: Jens <jens@orion>
|
||||
## Created: 2020-10-04
|
||||
|
||||
function matte = supermatte (im_rgb, ref_rgb, k_e)
|
||||
function [matte, dev, conf] = supermatte (im_rgb, ref_rgb, k_e)
|
||||
|
||||
im_minus_ref = im_rgb - ref_rgb;
|
||||
var_im_minus_ref = var(im_minus_ref, 0, 3);
|
||||
|
||||
# The base matte
|
||||
matte = 1-exp(-k_e*var_im_minus_ref);
|
||||
|
||||
# Deviation from reference color
|
||||
dev = vecnorm(im_minus_ref, 2, 3);
|
||||
|
||||
# Deviation from gray
|
||||
conf = mean(abs(im_minus_ref), 3);
|
||||
endfunction
|
||||
|
||||