%
% [Pras07] L. Prasad: "Rectification of the chordal axis transform skeleton% and criteria for shape decomposition", Image and Vision Computing,
% 25:1557-1571, 2007.% ;
% see also %
%% Credit% (ISR-2/LANL)
%%% See also
% Ressembles: % .
% .% Requires:
% .
%% Function implementationfunction varargout = drawgestalt(X, Y, disp)
%%
% checking/setting parameters
error(nargchk(0, 3, nargin, 'struct'));error(nargoutchk(0, 3, nargout, 'struct'));
%X=150; Y=200;
if nargin<3, disp = false; if nargin<2, Y = [];
if nargin<1, X =150;
if nargout == 0, disp = true; end end
endend
if nargin==1 && islogical(X)
disp = X; X = 150;
end
gap = round(X/4);
if nargout==0 && ~disp error('drawgestalt:inputwarning', 'stupid you... see help and try again');
end
if isempty(Y), Y = X; end % default square size
if disp, if ~isempty(ver('images'))
se = strel('square',3); fdisp = @(x) imdilate(x,se);
else fdisp = @(x) x;
end h = figure; hold on;
else if nargout==3,
warning('drawgestalt:inputwarning', ... 'no figure displayed - empty ''h'' argument returned');
h = []; end
end
%%% main calculation
[C, S] = drawgestalt_base(X, Y, gap);
%%
% display
if disp, % junction type 1: endlink1
subplot(4,4,1), imagesc(~fdisp(C.I)), axis image off; title('junction type 1 (endlink1)');
% intersection type L subplot(4,4,2), imagesc(~fdisp(C.L)), axis image off;
title('L junction'); % intersection type Y
subplot(4,4,3), imagesc(~fdisp(C.Y)), axis image off; title('Y junction');
% intersection type T subplot(4,4,4), imagesc(~fdisp(C.T)), axis image off;
title('Y junction'); % multiple junction type 1
subplot(4,4,5), imagesc(~fdisp(C.X)), axis image off; title('multiple junction');
% incomplete contour subplot(4,4,6), imagesc(~fdisp(C.E1)), axis image off;
title('incomplete'); % composed incomplete contours
subplot(4,4,7), imagesc(~fdisp(C.E2)), axis image off; title('composed incomplete');
% single-sided neck N = S.N1; N(10:X-10,10) = true; N(10:round(X/2)+10,Y-10) = true;
subplot(4,4,9), imagesc(~fdisp(N)), axis image off; title('single-sided neck');
% double-sided neck N2 = S.N2; N2(10:X-10,10) = true; N2(10:X-10,Y-10) = true;
subplot(4,4,10), imagesc(~fdisp(N2)), axis image off; title('double-sided neck');
% tapering shape F = S.F; F(10:X-10,10) = true; F(round(X/2)-10:round(X/2)+10,Y-10) = true;
subplot(4,4,11), imagesc(~fdisp(F)), axis image off; title('tapering shape');
% intersection type Y sY=S.Y; sY(10:round(X/2)-15,10) = true; sY(10:round(X/2)-15,Y-10) = true;
sY(X-10,round(Y/2)-20:round(Y/2)+20) = true; subplot(4,4,12), imagesc(~fdisp(sY)), axis image off;
title('Y-shape'); % intersection type T
T = S.T; T(20:round(X/2),10) = true; T(20:round(X/2),Y-10) = true; T(X-10,round(Y/2)-round(gap/2):round(Y/2)+round(gap/2)) = true;
subplot(4,4,13), imagesc(~fdisp(T)), axis image off; title('T-shape');
% intersection type L L = S.L; L(20,20:20+gap) = true; L(X-10-gap:X-10,round(2*Y/3)) = true;
subplot(4,4,14), imagesc(~fdisp(L)),axis image off; title('L-shape');
% main figure's title colormap gray, suptitle('''Gestalt-like'' contours and shapes');
hold off;end
%%
% final outputsif nargout>=1, varargout{1} = C;
if nargout>=2, varargout{2} = S; if nargout==3, varargout{3} = h; end
endend
end % end of drawgestalt
##### SOURCE END #####-->