From 474f11c05ab6cc874368e8a0a0291fecf54a2d15 Mon Sep 17 00:00:00 2001 From: John Lawson <j.m.lawson@soton.ac.uk> Date: Mon, 13 Nov 2023 20:43:59 +0000 Subject: [PATCH] bug fixes to image preprocessing --- core/preproc/filter_norm.m | 2 +- core/preproc/image_preprocess.m | 34 ++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/core/preproc/filter_norm.m b/core/preproc/filter_norm.m index ba31633..1bd8d57 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 86baf43..ed679ca 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 -- GitLab