- added prj_load
- delete result files - added project files with alpha bg markings git-svn-id: http://moon:8086/svn/matlab/trunk@147 801c6759-fa7c-4059-a304-17956f83a07c
|
After Width: | Height: | Size: 464 KiB |
|
Before Width: | Height: | Size: 567 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 658 KiB |
|
Before Width: | Height: | Size: 4.3 MiB |
|
Before Width: | Height: | Size: 5.4 MiB |
@@ -0,0 +1,66 @@
|
|||||||
|
## 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} =} prj_load (@var{input1}, @var{input2})
|
||||||
|
##
|
||||||
|
## @seealso{}
|
||||||
|
## @end deftypefn
|
||||||
|
|
||||||
|
## Author: Jens <jens@orion>
|
||||||
|
## Created: 2020-10-04
|
||||||
|
|
||||||
|
function [im_rgb, ref_rgb] = prj_load(prj_name)
|
||||||
|
extensions = {'.png'};
|
||||||
|
name_im = ''
|
||||||
|
for i=1:length(extensions),
|
||||||
|
ext = extensions{i}
|
||||||
|
name_cand = strcat(prj_name, ext)
|
||||||
|
if isfile(name_cand)
|
||||||
|
name_im = name_cand;
|
||||||
|
break;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if isempty(name_im)
|
||||||
|
error("File Not found")
|
||||||
|
end
|
||||||
|
|
||||||
|
[im, m, a] = imread(name_im);
|
||||||
|
if length(a) == 0
|
||||||
|
error("Alpha channel not found")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get image dimensions
|
||||||
|
[w, h, nc] = size(im)
|
||||||
|
|
||||||
|
# Get RGBA data
|
||||||
|
im_rgb = im2double(im);
|
||||||
|
im_a = im2double(a);
|
||||||
|
|
||||||
|
# Find background sample area in alpha channel
|
||||||
|
# And create reference data
|
||||||
|
ref_sample_indices = find(im_a < 0.5);
|
||||||
|
zzz = reshape(im_rgb, w*h, nc);
|
||||||
|
ref = mean(zzz(ref_sample_indices, :))
|
||||||
|
ref_rgb = toRef(ref, size(im_rgb));
|
||||||
|
|
||||||
|
function r = toRef(ref, d)
|
||||||
|
r = repmat(reshape(ref,1, 1, 3), d(1), d(2));
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
endfunction
|
||||||