%
%% Credit% (ISR-2/LANL)
%%% See also
% Ressembles:% <../filter/convolution.html |CONVOLUTION|>,
% <../kernel/hourglasskernel.html |HOURGLASSKERNEL|>,% <../kernel/gausskernel.html |GAUSSKERNEL|>,
% <../kernel/dirgausskernel.html |DIRGAUSSKERNEL|>,% ,
% ,% ,
% ,% .
% Requires:% .
%% Function implementation
function S = smoothfilt (I,varargin)
%% % parsing and checking parameters
error(nargchk(1, 22, nargin, 'struct'));
error(nargoutchk(1,1, nargout, 'struct'));
if ~(isnumeric(I)) error('smoothfilt:inputerror','matrices are required in input');
end
p = createParser('SMOOTHFILT'); % optional parameters
p.addOptional('rho',1., @(x)x>=0); p.addParamValue('sm', 'fast', @(x) ischar(x) && ...
any(strcmpi(x,{'fast','imgaussian', 'matlab','conv2',... 'conv','convolution', 'ani','hourglass'})));
p.addParamValue('hsize',[], @(x)isscalar(x) || isempty(x));p.addParamValue('samp',1, @(x)isscalar(x) && round(x)==x && x>=1);
p.addParamValue('thez', 8, @(x)isscalar(x) && round(x)==x);p.addParamValue('sigt', .4, @(x)isscalar(x) && isfloat(x) && x>0);
p.addParamValue('theta', [], @(x)isnumeric(x) && ndims(x)>=2);
% parse and validate all input argumentsp.parse(varargin{:});
p = getvarParser(p);
%% % checking parameters and setting variable
C = size(I,3);
if any(strcmp(p.sm,{'ani','hourglass'}))
if isempty(p.theta) error('smoothfilt:errorinput',...
['input fields must be provided with option ' p.sm]); elseif ndims(p.theta)==2 && (any(p.theta(:)<0) || any(p.theta(:)>pi))
p.theta = mod(p.theta,pi); elseif ndims(p.theta)==3
p.theta = mod(atan2(p.theta(:,:,2),p.theta(:,:,1)),pi); end
if ~(size(p.theta,1)==size(I,1) && size(p.theta,2)==size(I,2)) error('smoothfilt:errorinput',...
'input directional field and image must have same size'); end
end
%% % linear or nonlinear spatial smoothing
S = smoothfilt_base(I, p.rho, p.sm, p.hsize, p.samp, p.thez, p.sigt, p.theta);
%%
% display
if p.disp figure, imagesc(rescale(S,0,1)), axis image off, title('smoothed image');
if C==1, colormap gray; end;end
end % end of smoothfilt
##### SOURCE END #####
-->