- different approach
git-svn-id: http://moon:8086/svn/matlab/trunk@141 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 443 KiB After Width: | Height: | Size: 3.0 MiB |
+33
-11
@@ -28,14 +28,16 @@ im = im2double(imread(img_name));
|
|||||||
im_rgb = imresize(im, 1);
|
im_rgb = imresize(im, 1);
|
||||||
se = strel('square',3)
|
se = strel('square',3)
|
||||||
|
|
||||||
#ref_rgb = toRef([0.3 0.4 0.65], size(im_rgb));
|
ref = [0.3 0.4 0.65]; # cineon_before
|
||||||
ref_rgb = toRef([0.2 0.6 0.95], size(im_rgb));
|
#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_ds = 0.2;
|
||||||
k_c_matte = 1.0
|
k_e_matte = 5.0
|
||||||
k_e_matte = 3
|
|
||||||
|
|
||||||
k_c_edge = 3.0
|
|
||||||
k_e_edge = 3.0
|
k_e_edge = 3.0
|
||||||
|
|
||||||
close all;
|
close all;
|
||||||
@@ -44,8 +46,15 @@ figure;
|
|||||||
imshow(ref_rgb);
|
imshow(ref_rgb);
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
matte = min(1, k_c_matte*similarity_rgb(im_rgb, ref_rgb, k_e_matte));
|
matte_p = imnorm(im_rgb, ref_rgb);
|
||||||
#matte = mask_clip_below(matte, 0.5);
|
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")
|
imshow(matte); title("matte")
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
@@ -53,8 +62,7 @@ final = max(0, im_rgb - k_ds*matte.*ref_rgb).*matte;
|
|||||||
imshow(final); title("final")
|
imshow(final); title("final")
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
edges = k_c_edge*coloredges(final, ref_rgb, k_e_edge);
|
edges = coloredges(final, ref_rgb, k_e_edge);
|
||||||
#edges = mask_clip_below(edges, 0.25);
|
|
||||||
imshow(edges); title("edges")
|
imshow(edges); title("edges")
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
@@ -69,7 +77,21 @@ function r = toRef(ref, d)
|
|||||||
r = repmat(reshape(ref,1, 1, 3), d(1), d(2));
|
r = repmat(reshape(ref,1, 1, 3), d(1), d(2));
|
||||||
endfunction
|
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));
|
s = 1-exp(-k*vecnorm (im - ref, 2, 3));
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 10 MiB |
Reference in New Issue
Block a user