.
%%% Remarks
% direction/orientation of the outputs of common functions used for gradient% estimation:
%% REPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASH> gy
% [gx,gy] = grdmask(a,'method','axis','ij'); |% [gx,gy] = grad(a); gx |
% [gx,gy] = GRDSMOOTH(a,'der',,'axis','ij'); \|/%
% REPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASH> gx% |
% [gx,gy] = gradient(a); gy |% \|/
%% /|\
% [gx,gy] = grdmask(a,'method','axis','xy'); gy |% [gx,gy] = GRDSMOOTH(a,'der',,'axis','xy'); |
% REPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASH> gx%
% See C.Luengo discussion on Gaussian filtering and Gaussian derivation:%
% %
%% Credit% (ISR-2/LANL)
%%% See also
% Ressembles:% ,
% ,% <../filter/smoothfilt.html |SMOOTHFILT|>,
% .% Requires:
% .
%% Function implementationfunction [gx,gy,varargout] = grdsmooth(I,varargin)
%%
% parsing and checking parameters
error(nargchk(1, 16, nargin, 'struct'));error(nargoutchk(1, 4, nargout, 'struct'));
% mandatory parameter
if ~isnumeric(I) error('grdsmooth:inputerror','a matrix is required in input');
end
p = createParser('GRDSMOOTH'); % create an instance of the inputParser class.% optional parameters
p.addOptional('sigma',1., @(x)x>=0); % just for testingp.addOptional('der', 'fast', @(x)ischar(x) && ...
any(strcmpi(x,{'matlab','vista','kroon','kovesi','fast','conv','fleck', ... 'opt', 'tap5','tap7','sob','sobel','prew','opt','circ','ana','lue'})));
p.addParamValue('hsize',[], @(x)isscalar(x) || isempty(x));p.addParamValue('axis','ij',@(x)ischar(x) && any(strcmpi(x,{'ij','xy'})));
% parse and validate all input arguments
p.parse(varargin{:}); p = getvarParser(p);
%%
% checking variables
% prior checking for external called functionsif (strcmp(p.der,'ana') || strcmp(p.der,'vista') || ...
strcmp(p.der,'lue')) && p.sigma==0 error('grdsmooth:incompatible',[ p.der ' incompatible with sigma=0']);
elseif any(strcmp(p.der,{'kroon','fast'})) && ...
(~exist('imgaussian','file') || ~exist('derivatives','file')) error('grdsmooth:unknownfunction','Kroon''s toolbox to be loaded');
elseif any(strcmp(p.der,{'kovesi','tap5','tap7'})) && ...
(~exist('derivative5','file') || ~exist('derivative7','file')) error('grdsmooth:unknownfunction','Kovesi''s toolbox to be loaded');
end
%%
% main computation
[gx, gy, mag, or] = grdsmooth_base(I, p.sigma, p.der, p.hsize, p.axis);
if nargout>=3 varargout{1} = mag;
if nargout==4, varargout{2} = or; end;end
%%
% displayif p.disp
figure, ncols = 2; if nargout>=3, nrows = 2; else nrows = 1; end
subplot(nrows,ncols,1), imagesc(rescale(gx,0,1)), axis image off title(['gx - axis ''' p.axis '''']); if size(gx,3)==1, colormap gray, end;
subplot(nrows,ncols,2), imagesc(rescale(gy,0,1)), axis image off title(['gy - axis ''' p.axis '''']); if size(gy,3)==1, colormap gray, end;
if nargout>=3 subplot(2,2,3), imagesc(rescale(mag,0,1)), axis image off
title('mag'); if size(mag,3)==1, colormap gray, end; if nargout==4
subplot(2,2,4), imagesc(rescale(or,0,1)), axis image off title('orient'); if size(or,3)==1, colormap gray, end;
end end
end
end % end of grdsmooth
##### SOURCE END #####-->