- added matlab scripts
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
## 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
|
||||
## <https://www.gnu.org/licenses/>.
|
||||
|
||||
## -*- texinfo -*-
|
||||
## @deftypefn {} {@var{retval} =} bluescreen (@var{input1}, @var{input2})
|
||||
##
|
||||
## @seealso{}
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Jens <jens@orion>
|
||||
## Created: 2020-10-03
|
||||
|
||||
# chromakey('adventure_rose', 20, 10)
|
||||
# chromakey('cineon_before', 200, 100)
|
||||
|
||||
function eval_matte (prj_name, k_e_matte)
|
||||
|
||||
clip_white_thresh = 0.80;
|
||||
clip_white_amp = 3;
|
||||
|
||||
clip_black_thresh = 0.20;
|
||||
clip_black_amp = 3;
|
||||
|
||||
[im_rgb, ref_rgb] = prj_load(prj_name);
|
||||
|
||||
close all;
|
||||
|
||||
pre_filtered = im_rgb - ref_rgb;
|
||||
pre_filtered_p = max(0,pre_filtered);
|
||||
pre_filtered_n = -min(0,pre_filtered);
|
||||
|
||||
figure;
|
||||
imshow(abs(pre_filtered)); title("pre_filtered")
|
||||
|
||||
figure;
|
||||
filtered_var = var(pre_filtered, 0, 3);
|
||||
|
||||
kn = 1/max(max(filtered_var(:)))
|
||||
var_n = k_e_matte*kn*filtered_var;
|
||||
matte = min(1, var_n);
|
||||
imshow(matte); title("var")
|
||||
|
||||
figure;
|
||||
filtered_norm = vecnorm(pre_filtered, 2, 3);
|
||||
imshow(filtered_norm); title("norm")
|
||||
|
||||
figure;
|
||||
intermediate = im_rgb.*matte;
|
||||
imshow(intermediate); title("intermediate")
|
||||
|
||||
figure;
|
||||
edges = exp(-1.7*k_e_matte*var(intermediate - ref_rgb, 0, 3));
|
||||
imshow(edges); title("edges")
|
||||
|
||||
figure;
|
||||
final = intermediate - edges.*ref_rgb;
|
||||
imshow(final); title("final")
|
||||
|
||||
imwrite(intermediate, sprintf('%s.intermediate.png',prj_name),'png','alpha', matte);
|
||||
imwrite(edges, sprintf('%s.edges.png',prj_name),'png');
|
||||
imwrite(final, sprintf('%s.final.png',prj_name),'png','alpha', matte);
|
||||
|
||||
Reference in New Issue
Block a user