diff --git a/core/preproc/filter_norm.m b/core/preproc/filter_norm.m index ba31633d031ccaecea5c20f91064c639d988ce76..1bd8d5735d4054c9cd86dc4ff16ab2d648137030 100644 --- a/core/preproc/filter_norm.m +++ b/core/preproc/filter_norm.m @@ -21,4 +21,4 @@ function [im_filt,nvpair] = filter_norm(im, nvpair) sz = nvpair.size; sz = sz + mod(sz+1,2); % round to nearest odd integer [minv, maxv] = minmaxfiltnd(im, sz); - im_filt = (im - minv) ./ max(maxv-minv, 1/max_gain); \ No newline at end of file + im_filt = (im - minv) ./ max(maxv-minv, 1/nvpair.max_gain); \ No newline at end of file diff --git a/core/preproc/image_preprocess.m b/core/preproc/image_preprocess.m index 86baf43050dcc9307cf1aa2c67824703c437492c..ed679ca2fbe1e9fd7df8f19f084257a5216e3fe7 100644 --- a/core/preproc/image_preprocess.m +++ b/core/preproc/image_preprocess.m @@ -15,37 +15,41 @@ function im_filt = image_preprocess(im, filters) for i = 1 : n_filters 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); - if strcmp(filter.type, 'gaussian') + if strcmp(ftype, 'gaussian') im_filt = filter_gaussian(im_filt, args{:}); - elseif strcmp(filter.type, 'custom') + elseif strcmp(ftype, 'custom') im_filt = filter_custom(im_filt, args{:}); - elseif strcmp(filter.type, 'ssmin') + elseif strcmp(ftype, 'ssmin') im_filt = filter_ssmin(im_filt, args{:}); - elseif strcmp(filter.type, 'ssbg') + elseif strcmp(ftype, 'ssbg') im_filt = filter_ssbg(im_filt, args{:}); - elseif strcmp(filter.type, 'lmax') + elseif strcmp(ftype, 'lmax') im_filt = filter_lmax(im_filt, args{:}); - elseif strcmp(filter.type, 'levelize') + elseif strcmp(ftype, 'levelize') im_filt = filter_levelize(im_filt, args{:}); - elseif strcmp(filter.type, 'median') + elseif strcmp(ftype, 'median') im_filt = filter_median(im_filt, args{:}); - elseif strcmp(filter.type, 'norm') + elseif strcmp(ftype, 'norm') im_filt = filter_norm(im_filt, args{:}); - elseif strcmp(filter.type, 'norm2') + elseif strcmp(ftype, 'norm2') im_filt = filter_norm2(im_filt, args{:}); - elseif strcmp(filter.type, 'mednorm') + elseif strcmp(ftype, 'mednorm') im_filt = filter_norm2(im_filt, args{:}); - elseif strcmp(filter.type, 'clip') + elseif strcmp(ftype, 'clip') im_filt = filter_clip(im_filt, args{:}); - elseif strcmp(filter.type, 'transpose') + elseif strcmp(ftype, 'transpose') im_filt = filter_transpose(im_filt, args{:}); - elseif strcmp(filter.type, 'invert') + elseif strcmp(ftype, 'invert') im_filt = filter_invert(im_filt, args{:}); - elseif strcmp(filter.type, 'null') + elseif strcmp(ftype, 'null') im_filt = filter_null(im_filt); else - error('unrecognised filter type %s', filter.type); + error('unrecognised filter type %s', ftype); end end end