%
% [TD01] D. Tschumperle and R. Deriche: "Constrained and unconstrained% PDE's for vector image restoration", Proc. SCIA, pp. 153-160, 2001.
% %
% [TD02] D. Tschumperle and R. Deriche: "Diffusion PDE's on vector-valued% images", IEEE Signal Processing Magazine, 19(5):16-25, 2002.
% %
% [Scheun03] P. Scheunders: "A wavelet representation of multispectral% images", Frontiers of Remote Sensing Information Processing, pp.
% 197-224. World Scientific, 2003.%
%% [Tschum06] D. Tschumperle: "Fast anisotropic smoothing of multivalued
% images using curvature-preserving PDE's", International Journal of% Computer Vision, 68(1):65-82, 2006.
% %
%% Credit% (ISR-2/LANL)
%%% See also
% Ressembles:% ,
% ,% <../filter/smoothfilt.html |SMOOTHFILT|>.
% Requires:% .
%% Function implementation
function [gx2, gy2, gxy, varargout] = grd2gst(gx, gy, varargin)
%%% parsing and checking parameters
error(nargchk(2, 26, nargin, 'struct'));
error(nargoutchk(3, 5, nargout, 'struct'));
if ~(isnumeric(gx) && isnumeric(gy)) error('grd2gst:inputerror','matrices are required in input');
end
p = createParser('GRD2GST'); % create an instance of the inputParser class.% optional parameters
p.addOptional('rho',1., @(x)x>=0); % just for testingp.addOptional('int', 'fast', @(x)islogical(x) || (ischar(x) && ...
any(strcmpi(x,{'matlab','conv','fast','ani'}))));p.addParamValue('hsize',[], @(x)isscalar(x) || isempty(x));
p.addParamValue('samp',1, @(x)isscalar(x) && round(x)==x && x>=1);p.addParamValue('tn', false, @(x)islogical(x));
p.addParamValue('thez', 8, @(x)isscalar(x) && round(x)==x);p.addParamValue('sigt', .4, @(x)isscalar(x) && isfloat(x) && x>0);
p.addParamValue('axis','ij',@(x)ischar(x) && any(strcmpi(x,{'ij','xy'})));p.addParamValue('eign','l1',@(x)ischar(x) && ...
any(strcmpi(x,{'abs','zen','l1','sap','sum','ndi','dif','koe'})));
% parse and validate all input argumentsp.parse(varargin{:});
p = getvarParser(p);
%% % checking parameters and setting variable
if size(gx) ~= size(gy)
error('grd2gst:inputerror','matrices must have same dimensions');end
if strcmp(p.axis,'ij')
% take the vector orthogonal to the input gradient tmp = gx; gx = gy; gy = -tmp;
% otherwise: horizontal OE and vertical SN derivatives have been passed % in gx and gy resp.
end
if islogical(p.int) && p.int, p.int = 'fast'; end % reset to default
%% % main computation
if nargout == 3
[gx2, gy2, gxy] = grd2gst_base(gx, gy, p.rho, p.int, p.hsize, ... p.samp, p.tn, p.thez, p.sigt, p.eign);
else
[gx2, gy2, gxy, mag, or] = grd2gst_base(gx, gy, p.rho, p.int, p.hsize, ... p.samp, p.tn, p.thez, p.sigt, p.eign);
varargout{1} = mag; if nargout == 5, varargout{2} = or; end;
end
%%% display
if p.disp figure,
ncols = 3; if nargout==3, nrows = 1; else nrows = 2; end subplot(nrows,ncols,1), imagesc(rescale(gx2,0,1)), axis image off,
title(['g_x^2 - axis ''' p.axis '''']); colormap gray; subplot(nrows,ncols,2), imagesc(rescale(gy2,0,1)), axis image off,
title(['g_y^2 - axis ''' p.axis '''']); colormap gray; subplot(nrows,ncols,3), imagesc(rescale(gxy,0,1)), axis image off,
title(['g_x \cdot g_y - axis ''' p.axis '''']); colormap gray; if nargout>=4
subplot(nrows,ncols,4), imagesc(rescale(mag,0,1)), axis image off, title('mag'), colormap gray
subplot(2,3,5), imagesc(rescale(or,0,1)), axis image off, title('or'), colormap gray
endend
end % end of grd2gst
##### SOURCE END #####-->