%
% [GS09b] J. Grazzini and P. Soille: "Edge-preserving smoothing using a % similarity measure in adaptive geodesic neighbourhoods", Pattern
% Recognition, 42(10):2306-2316, 2009.%
%% [GSD10] J. Grazzini, S. Dillard and P. Soille: "Multichannel image
% regularisation using anisotropic geodesic filtering", Proc. ICPR,% pp. 2664-2667, 2010.
% %
%% Credit% (ISR-2/LANL)
% %% See also
% Ressembles:% ,
% ,% ,
% ,% <../derive/gstsmooth.html |GSTSMOOTH|>,
% <../derive/grd2gst.html |GRD2GST|>,% <../propagation/fmmisopropagation.html |FMMISOPROPAGATION|>,
% <../propagation/fmmanisopropagation.html |FMMANISOPROPAGATION|>,% <../propagation/potential2front.html |POTENTIAL2FRONT|>,
% <../propagation/im2potential.html |IM2POTENTIAL|>,% <../propagation/fmm_base.html |FMM_BASE|>,
% <../pdem/pdem.html |PDEM|>.% Requires:
% .
% note: you can 'play' with the parameter method as other methods are% accepted (see function IM2POTENTIAL_BASE) but not mentioned here
%% Function implementation
function F = geodesicfilt(I,varargin)
%%% parsing parameters
error(nargchk(1, 25, nargin, 'struct'));
error(nargoutchk(1, 2, nargout, 'struct'));
% mandatory parameterif ~isnumeric(I)
error('geodesicfilt:inputerror','a matrix is required in input'); end
% optional parameters
p = createParser('GEODESICFILT'); % create an instance of the inputParser class.p.addOptional('method', 'iso', @(x)ischar(x) && ...
any(strcmpi(x,{'iso','isotropic','ani','anisotropic', ... 'gstninv','gst','gstorth','gstn','gstn1','gstn2','gstn3','gstcoh'})));
p.addOptional('wei', 2, @(x) (isscalar(x) && x>=-5) || ... (ischar(x) && any(strcmpi(x,{'scale','gauss','median'}))));
p.addOptional('winsize', 11, @(x)isscalar(x) && isfloat(x) && x>=3);% additional optional parameters
p.addParamValue('iter', 1, @(x)isscalar(x) && round(x)==x && x>=1);p.addParamValue('rho', 3, @(x)isscalar(x) && isfloat(x) && x>=0);
p.addParamValue('sig', 1, @(x)isscalar(x) && isfloat(x) && x>=0);p.addParamValue('der', 'fast', @(x)islogical(x) || (ischar(x) && ...
any(strcmpi(x,{'matlab','vista','fast','conv','fleck', ... 'tap5','tap7','sob','opt','ana'}))));
p.addParamValue('int', 'fast', @(x)islogical(x) || (ischar(x) && ... any(strcmpi(x,{'matlab','conv','fast','ani'}))));
p.addParamValue('samp', 1, @(x)isscalar(x) && round(x)==x && x>=1 && x<=5);p.addParamValue('eign','l1',@(x)ischar(x) && ...
any(strcmpi(x,{'abs','zen','l1','sap','sum','ndi','dif','koe'})));p.addParamValue('a', [1 1], @(x)isscalar(x) || ...
(isvector(x) && length(x)==2));
% parse and validate all input argumentsp.parse(varargin{:});
p = getvarParser(p);
%%% checking/setting parameters
if strcmp(p.method,'anisotropic'), p.method = 'ani';
elseif strcmp(p.method,'isotropic'), p.method = 'iso';end
if ischar(p.wei)
if strcmpi(p.wei,'gauss'), p.wei = 1; % weighting gaussian with alpha=1 elseif strcmpi(p.wei,'scale'), p.wei = -1; % 1/D weighting function
else p.wei = 0; % median end
end
% set some defaultif any(strcmpi(p.method,{'gstnorm1','gstnorm2','gstnorm3'}))
if isempty(p.a), p.a = [1 2]; elseif length(p.a)==1, p.a = [p.a p.a+eps];
endend
if isempty(p.a), p.a = 1; end
%%
% main calculation
F = geodesicfilt_base(I, p.method, p.iter, p.wei, p.winsize, p.a, ... p.rho, p.sig, p.der, p.int, p.samp, p.eign);
%%
% display
if p.disp figure, imagesc(rescale(F,0,1)), axis image off,
title(['geo-filtered image - method ' p.method]); if size(F,3)==1; colormap gray; end
end
end % end of geodesicfilt
##### SOURCE END #####-->