%
% [ASSLFS10] R. Achanta, A. Shaji, K. Smith, A. Lucchi, P. Fua and S. % Susstrunk: "SLIC superpixels", EPFL Technical Report no. 149300, 2010.
% %
%% Credit% (ISR-2/LANL)
%%% See also
% Ressembles:% ,
% ,% .
% Requires:% .
%% Function implementation
function [S, varargout] = regionclean(L, varargin)
if isempty(ver('images')) % note that REGIONPROPS is used in REGIONCLEAN_BASE
error('regionclean:errortoolbox', ... 'Image Processing toolbox required for calling REGIONPROPS');
end
%%% parsing parameters
error(nargchk(1, 27, nargin, 'struct'));
error(nargoutchk(1, 1, nargout, 'struct'));
% mandatory parameterif ~isnumeric(L)
error('regionadjacency:inputerror','image of integer labels required in entry'); end
p = createParser('REGIONCLEAN'); % create an instance of the inputParser class.
p.addParamValue('area', 0.1, @(x)isempty(x) || (isscalar(x) && x>0));p.addParamValue('solid', [], @(x)isempty(x) || (isscalar(x) && x>0 && x<=1));
% p.addParamValue('isoper', [], @(x)isempty(x) || (isscalar(x) && x>=0 && x<=1));% % 'isoper' : (optional) threshold 0=0 && x<=1));
% p.addParamValue('eccent', [], @(x)isempty(x) || (isscalar(x) && x>=0 && x<=1));% % 'eccent' : (optional) threshold 0=1 && x<=20);
p.addParamValue('Ck', [], @(x)isempty(x) || (isnumeric(x) && all(x(:)>=0)));p.addParamValue('ColCk', [], @(x)isempty(x) || isnumeric(x));
p.addParamValue('compress', false, @islogical);
% parse and validate all input argumentsp.parse(varargin{:});
p = getvarParser(p);
%% % setting variables
[X,Y] = size(L);
if ~isempty(p.Ck) && ~isequal(max(unique(L(:))),size(Ck,1))
error('regionclean:errorinput', ... ['the length of the centroid matrix must be equal to the maximal ' ...
'label value found in the input segmentation image ']);
elseif ~isempty(p.ColCk) && ~isempty(p.Ck) && ... ~isequal(size(ColCk,1),size(Ck,1))
error('regionclean:errorinput', ... 'centroid matrix and representative matrix must have same length');
end
features = {''}; thresholds = [];if ~isempty(p.area) && p.area1, varargout{1} = p.Ck;
if nargout>2, varargout{2} = p.ColCk; endend
if p.compress, S = compressrange(S); end
%%
% display
if p.disp figure,
subplot(1,2,1), imagesc(label2rgb(L.*(imdilate(L,ones(3,3))-L==0))); axis image off, title('input regions');
subplot(1,2,2), imagesc(label2rgb(S.*(imdilate(S,ones(3,3))-S==0))); axis image off, title('cleaned regions');
end
end % end of regionclean
##### SOURCE END #####-->