%
%% Credit% (ISR-2/LANL)
% %% See also
% Ressembles:% ,
% ,% ,
% .% Requires:
% .
%% Function implementationfunction WMI = wmedfilt2(I,wk)
error(nargchk(2, 2, nargin, 'struct'));
error(nargoutchk(1, 1, nargout, 'struct'));
%% % parsing and checking parameters
if ~isnumeric(I) error('wmedfilt2:inputerror','matrice is required in input');
end
p = createParser('WMEDFILT2'); % create an instance of the inputParser class.p.addRequired('wk', @(x) isequal(round(x),x));
% parse and validate all input arguments
p.parse(wk); p = getvarParser(p);
%%
% internal variables and further checking
C = size(I,3);[x y c] = size(p.wk);
if ~isequal(round(p.wk),p.wk)
warning('wmedfilt2:inputwarning',... 'the input weighting matrix must have integer values');
end
if c~=1 && c~=C error('wmedfilt2:inputargument', ...
'input kernel must have 1 channel or the same number as the input');end
cpos = find(p.wk<0,1,'first');
if isempty(cpos) && (x~=y || mod(x,2)~=1) error('wmedfilt2:inputargument',...
'input kernel must be square shaped with odd size');end
%%
% main processing
WMI = wmedfilt2_base(I, p.wk);
%%% display
if p.disp
figure, imagesc(rescale(WMI,0,1)), axis image off; if C==1, colormap gray; end;
title('weighted median filtered image');end
end % end of wmedfilt2
##### SOURCE END #####
-->