- different approach

git-svn-id: http://moon:8086/svn/matlab/trunk@141 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
2020-10-03 20:25:31 +00:00
parent bfd6fb4f3d
commit 281c35bcc9
3 changed files with 33 additions and 11 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 KiB

After

Width:  |  Height:  |  Size: 3.0 MiB

+33 -11
View File
@@ -28,14 +28,16 @@ im = im2double(imread(img_name));
im_rgb = imresize(im, 1);
se = strel('square',3)
#ref_rgb = toRef([0.3 0.4 0.65], size(im_rgb));
ref_rgb = toRef([0.2 0.6 0.95], size(im_rgb));
ref = [0.3 0.4 0.65]; # cineon_before
#ref = 0.2 0.6 0.95]; # adventure_rose
ref_c = 1 - ref
ref_rgb = toRef(ref, size(im_rgb));
ref_rgb_c = toRef(ref_c, size(im_rgb));
k_ds = 0.2;
k_c_matte = 1.0
k_e_matte = 3
k_c_edge = 3.0
k_e_matte = 5.0
k_e_edge = 3.0
close all;
@@ -44,8 +46,15 @@ figure;
imshow(ref_rgb);
figure;
matte = min(1, k_c_matte*similarity_rgb(im_rgb, ref_rgb, k_e_matte));
#matte = mask_clip_below(matte, 0.5);
matte_p = imnorm(im_rgb, ref_rgb);
imshow(matte_p); title("matte_p")
figure;
matte_n = imnorm(im_rgb, ref_rgb_c);
imshow(matte_n); title("matte_n")
figure;
matte = exp(-k_e_matte*(matte_n - matte_p));
imshow(matte); title("matte")
figure;
@@ -53,8 +62,7 @@ final = max(0, im_rgb - k_ds*matte.*ref_rgb).*matte;
imshow(final); title("final")
figure;
edges = k_c_edge*coloredges(final, ref_rgb, k_e_edge);
#edges = mask_clip_below(edges, 0.25);
edges = coloredges(final, ref_rgb, k_e_edge);
imshow(edges); title("edges")
figure;
@@ -69,7 +77,21 @@ function r = toRef(ref, d)
r = repmat(reshape(ref,1, 1, 3), d(1), d(2));
endfunction
function s = similarity_rgb(im, ref, k)
function hsv = toHsv(in, gain_hsv)
hsv = rgb2hsv(in) .* toRef(gain_hsv, size(in));
endfunction
function s = imnorm(im, ref)
s = vecnorm (im - ref, 2, 3);
endfunction
function s = similarity(im, ref, k)
s = 1-exp(-k*vecnorm (im - ref, 2, 3));
endfunction
function s = similarity_hsv(im_rgb, ref_rgb, k, weigth)
im = toHsv(im_rgb, weigth);
ref = toHsv(ref_rgb, weigth);
s = 1-exp(-k*vecnorm (im - ref, 2, 3));
endfunction
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 10 MiB