- 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:
Binary file not shown.
|
Before Width: | Height: | Size: 911 KiB After Width: | Height: | Size: 163 KiB |
+24
-8
@@ -23,9 +23,9 @@
|
|||||||
## Author: Jens <jens@orion>
|
## Author: Jens <jens@orion>
|
||||||
## Created: 2020-10-03
|
## 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 = im2double(imread(img_name));
|
||||||
im_rgb = imresize(im, 2);
|
im_rgb = imresize(im, 1);
|
||||||
se = strel('square',3)
|
se = strel('square',3)
|
||||||
|
|
||||||
ref_rgb = toRef([0 0.5 1], size(im_rgb));
|
ref_rgb = toRef([0 0.5 1], size(im_rgb));
|
||||||
@@ -35,20 +35,28 @@ close all;
|
|||||||
figure;
|
figure;
|
||||||
imshow(ref_rgb);
|
imshow(ref_rgb);
|
||||||
|
|
||||||
|
figure;
|
||||||
|
despilled_rgb_matte = im_rgb - k_sb*ref_rgb;
|
||||||
|
imshow(despilled_rgb_matte);
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
despilled_rgb = im_rgb - k_ds*ref_rgb;
|
despilled_rgb = im_rgb - k_ds*ref_rgb;
|
||||||
imshow(despilled_rgb);
|
imshow(despilled_rgb);
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
mask = min(1, k_gain*similarity(rgb2hsv(despilled_rgb), rgb2hsv(ref_rgb)));
|
matte = min(1, k_cw*similarity(despilled_rgb_matte, ref_rgb));
|
||||||
imshow(mask);
|
imshow(matte);
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
final = despilled_rgb.*mask;
|
final = despilled_rgb.*matte;
|
||||||
imshow(final);
|
imshow(final);
|
||||||
|
|
||||||
imwrite(final, 'final.png','png','alpha', mask);
|
figure;
|
||||||
imwrite(mask, 'alpha.png','png');
|
edges = coloredges(despilled_rgb_matte, ref_rgb);
|
||||||
|
imshow(edges);
|
||||||
|
|
||||||
|
imwrite(final, 'final.png','png','alpha', matte);
|
||||||
|
imwrite(matte, 'alpha.png','png');
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
@@ -57,7 +65,15 @@ function r = toRef(ref, d)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function s = similarity(im, ref)
|
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
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 MiB After Width: | Height: | Size: 736 KiB |
Reference in New Issue
Block a user