Skip to content
Snippets Groups Projects
Commit 474f11c0 authored by jml1g18's avatar jml1g18
Browse files

bug fixes to image preprocessing

parent 25e95af0
No related branches found
No related tags found
No related merge requests found
...@@ -21,4 +21,4 @@ function [im_filt,nvpair] = filter_norm(im, nvpair) ...@@ -21,4 +21,4 @@ function [im_filt,nvpair] = filter_norm(im, nvpair)
sz = nvpair.size; sz = nvpair.size;
sz = sz + mod(sz+1,2); % round to nearest odd integer sz = sz + mod(sz+1,2); % round to nearest odd integer
[minv, maxv] = minmaxfiltnd(im, sz); [minv, maxv] = minmaxfiltnd(im, sz);
im_filt = (im - minv) ./ max(maxv-minv, 1/max_gain); im_filt = (im - minv) ./ max(maxv-minv, 1/nvpair.max_gain);
\ No newline at end of file \ No newline at end of file
...@@ -15,37 +15,41 @@ function im_filt = image_preprocess(im, filters) ...@@ -15,37 +15,41 @@ function im_filt = image_preprocess(im, filters)
for i = 1 : n_filters for i = 1 : n_filters
filter = filters{i}; filter = filters{i};
ftype = filter.type;
% convert to name-value pairs
% need to remove type field as this is not an argument
filter = rmfield(filter, 'type');
args = namedargs2cell(filter); args = namedargs2cell(filter);
if strcmp(filter.type, 'gaussian') if strcmp(ftype, 'gaussian')
im_filt = filter_gaussian(im_filt, args{:}); im_filt = filter_gaussian(im_filt, args{:});
elseif strcmp(filter.type, 'custom') elseif strcmp(ftype, 'custom')
im_filt = filter_custom(im_filt, args{:}); im_filt = filter_custom(im_filt, args{:});
elseif strcmp(filter.type, 'ssmin') elseif strcmp(ftype, 'ssmin')
im_filt = filter_ssmin(im_filt, args{:}); im_filt = filter_ssmin(im_filt, args{:});
elseif strcmp(filter.type, 'ssbg') elseif strcmp(ftype, 'ssbg')
im_filt = filter_ssbg(im_filt, args{:}); im_filt = filter_ssbg(im_filt, args{:});
elseif strcmp(filter.type, 'lmax') elseif strcmp(ftype, 'lmax')
im_filt = filter_lmax(im_filt, args{:}); im_filt = filter_lmax(im_filt, args{:});
elseif strcmp(filter.type, 'levelize') elseif strcmp(ftype, 'levelize')
im_filt = filter_levelize(im_filt, args{:}); im_filt = filter_levelize(im_filt, args{:});
elseif strcmp(filter.type, 'median') elseif strcmp(ftype, 'median')
im_filt = filter_median(im_filt, args{:}); im_filt = filter_median(im_filt, args{:});
elseif strcmp(filter.type, 'norm') elseif strcmp(ftype, 'norm')
im_filt = filter_norm(im_filt, args{:}); im_filt = filter_norm(im_filt, args{:});
elseif strcmp(filter.type, 'norm2') elseif strcmp(ftype, 'norm2')
im_filt = filter_norm2(im_filt, args{:}); im_filt = filter_norm2(im_filt, args{:});
elseif strcmp(filter.type, 'mednorm') elseif strcmp(ftype, 'mednorm')
im_filt = filter_norm2(im_filt, args{:}); im_filt = filter_norm2(im_filt, args{:});
elseif strcmp(filter.type, 'clip') elseif strcmp(ftype, 'clip')
im_filt = filter_clip(im_filt, args{:}); im_filt = filter_clip(im_filt, args{:});
elseif strcmp(filter.type, 'transpose') elseif strcmp(ftype, 'transpose')
im_filt = filter_transpose(im_filt, args{:}); im_filt = filter_transpose(im_filt, args{:});
elseif strcmp(filter.type, 'invert') elseif strcmp(ftype, 'invert')
im_filt = filter_invert(im_filt, args{:}); im_filt = filter_invert(im_filt, args{:});
elseif strcmp(filter.type, 'null') elseif strcmp(ftype, 'null')
im_filt = filter_null(im_filt); im_filt = filter_null(im_filt);
else else
error('unrecognised filter type %s', filter.type); error('unrecognised filter type %s', ftype);
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment