diff --git a/chromakey/adventure_rose.jpg b/chromakey/adventure_rose.jpg new file mode 100755 index 0000000..40a8c20 Binary files /dev/null and b/chromakey/adventure_rose.jpg differ diff --git a/chromakey/alpha.png b/chromakey/alpha.png new file mode 100644 index 0000000..96b4049 Binary files /dev/null and b/chromakey/alpha.png differ diff --git a/chromakey/background.png b/chromakey/background.png new file mode 100755 index 0000000..77c6ae3 Binary files /dev/null and b/chromakey/background.png differ diff --git a/chromakey/bluescreen.m b/chromakey/bluescreen.m new file mode 100644 index 0000000..30c27d7 --- /dev/null +++ b/chromakey/bluescreen.m @@ -0,0 +1,63 @@ +## Copyright (C) 2020 Jens +## +## This program is free software: you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {} {@var{retval} =} bluescreen (@var{input1}, @var{input2}) +## +## @seealso{} +## @end deftypefn + +## Author: Jens +## Created: 2020-10-03 + +function retval = bluescreen (img_name, k_ds, k_gain) +im = im2double(imread(img_name)); +im_rgb = imresize(im, 2); +se = strel('square',3) + +ref_rgb = toRef([0 0.5 1], size(im_rgb)); + +close all; + +figure; +imshow(ref_rgb); + +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); + +figure; +final = despilled_rgb.*mask; +imshow(final); + +imwrite(final, 'final.png','png','alpha', mask); +imwrite(mask, 'alpha.png','png'); + +retval = 0; + +function r = toRef(ref, d) + r = repmat(reshape(ref,1, 1, 3), d(1), d(2)); +endfunction + +function s = similarity(im, ref) + s = abs(im(:,:,1) - ref(:,:,1)); +endfunction + +endfunction diff --git a/chromakey/final.png b/chromakey/final.png new file mode 100644 index 0000000..412bdc1 Binary files /dev/null and b/chromakey/final.png differ