- added detection of edges to be color corrected

git-svn-id: http://moon:8086/svn/matlab/trunk@138 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
2020-10-03 15:25:13 +00:00
parent 492e6e107d
commit e576b3cd5e
3 changed files with 24 additions and 8 deletions
+24 -8
View File
@@ -23,9 +23,9 @@
## Author: Jens <jens@orion>
## Created: 2020-10-03
function retval = bluescreen (img_name, k_ds, k_gain)
function retval = bluescreen (img_name, k_sb, k_ds, k_cw)
im = im2double(imread(img_name));
im_rgb = imresize(im, 2);
im_rgb = imresize(im, 1);
se = strel('square',3)
ref_rgb = toRef([0 0.5 1], size(im_rgb));
@@ -35,20 +35,28 @@ close all;
figure;
imshow(ref_rgb);
figure;
despilled_rgb_matte = im_rgb - k_sb*ref_rgb;
imshow(despilled_rgb_matte);
figure;
despilled_rgb = im_rgb - k_ds*ref_rgb;
imshow(despilled_rgb);
figure;
mask = min(1, k_gain*similarity(rgb2hsv(despilled_rgb), rgb2hsv(ref_rgb)));
imshow(mask);
matte = min(1, k_cw*similarity(despilled_rgb_matte, ref_rgb));
imshow(matte);
figure;
final = despilled_rgb.*mask;
final = despilled_rgb.*matte;
imshow(final);
imwrite(final, 'final.png','png','alpha', mask);
imwrite(mask, 'alpha.png','png');
figure;
edges = coloredges(despilled_rgb_matte, ref_rgb);
imshow(edges);
imwrite(final, 'final.png','png','alpha', matte);
imwrite(matte, 'alpha.png','png');
retval = 0;
@@ -57,7 +65,15 @@ function r = toRef(ref, d)
endfunction
function s = similarity(im, ref)
s = abs(im(:,:,1) - ref(:,:,1));
im = rgb2hsv(im);
ref = rgb2hsv(ref);
s = (im(:,:,1) - ref(:,:,1)).^2;
endfunction
function s = coloredges(im, ref)
im = rgb2hsv(im);
ref = rgb2hsv(ref);
s = max(0, im(:,:,1) - ref(:,:,1));
endfunction
endfunction