From 130f83a27f2a9dc8a15fc8908f15227817f8805e Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 7 Oct 2020 19:50:13 +0000 Subject: [PATCH] - improved clipping - matte is clipped matte white git-svn-id: http://moon:8086/svn/matlab/trunk@150 801c6759-fa7c-4059-a304-17956f83a07c --- chromakey/chromakey.m | 11 ++++++----- chromakey/clip_black.m | 4 +--- chromakey/clip_white.m | 5 +---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/chromakey/chromakey.m b/chromakey/chromakey.m index 0f11b3e..f1e12e5 100644 --- a/chromakey/chromakey.m +++ b/chromakey/chromakey.m @@ -29,11 +29,11 @@ function chromakey (prj_name, k_e_matte, k_e_edge) k_ds_matte = 1.0; -clip_white_thresh = 0.80; -clip_white_amp = 3; +clip_white_thresh = 0.60; +clip_white_amp = 5; -clip_black_thresh = 0.20; -clip_black_amp = 3; +clip_black_thresh = 0.40; +clip_black_amp = 5; [im_rgb, ref_rgb] = prj_load(prj_name); @@ -47,7 +47,8 @@ figure; imshow(conf); title("conf") matte_clipped_w = clip_white(matte, clip_white_thresh, clip_white_amp); -matte_clipped_b = clip_black(matte, clip_black_thresh, clip_black_amp); +matte_clipped_b = clip_black(matte_clipped_w, clip_black_thresh, clip_black_amp); +matte = matte_clipped_w; figure; imshow(matte_clipped_w.*matte_clipped_b); title("matte_{clipped}") diff --git a/chromakey/clip_black.m b/chromakey/clip_black.m index e4c9f07..8a51387 100644 --- a/chromakey/clip_black.m +++ b/chromakey/clip_black.m @@ -24,9 +24,7 @@ ## Created: 2020-10-04 function y = clip_black (x, thresh, k) -ind = find (x >= thresh); -y = x/k; -y(ind) = thresh/k + (x(ind)-thresh)*(1+thresh); +y = 1 - min(1, exp(-k*max(0,((1-thresh)-(1-x))))); endfunction diff --git a/chromakey/clip_white.m b/chromakey/clip_white.m index a186fcd..6ed26f0 100644 --- a/chromakey/clip_white.m +++ b/chromakey/clip_white.m @@ -25,9 +25,6 @@ function y = clip_white (x, thresh, k) -ind = find (x >= thresh); - -y = x; -y(ind) = thresh + (x(ind)-thresh)*k; +y = min(1, exp(-k*max(0,(thresh-x))) - exp(-k*thresh)); endfunction