function y = mmopentransf( f, type, n ) % MMOPENTRANSF Open transform. % % Y = MMOPENTRANSF( F, TYPE, N ) % % Input: % F - Binary image (logical uint8). % TYPE - String. Disk family: 'OCTAGON', 'CHESSBOARD', 'CITY-BLOCK', % 'LINEAR-V', LINEAR-H'. DEFAULT: 'OCTAGON'. % N - Maximum disk radius. DEFAULT: 65535. % % Output: % Y - Gray-scale (uint8 or uint16) image. % % Compute the open transform of a binary image. The value of the % pixels in the open transform gives the largest radius of the disk % plus 1, where the open by it is not empty at that pixel. The disk % sequency must satisfy the following: if r > s, rB is sB-open, i.e. % rB open by sB is equal rB. % % Limitation % ---------- % As this function can take quite a long time to execute, there is a % printout notifying the status of the execution. The radius of the % disk is informed for each open executed. % % Examples % -------- % % f = logical(uint8([... % 0 0 0 0 0 0 0 0;... % 0 0 1 1 1 1 0 0;... % 0 0 1 1 1 1 1 0;... % 0 1 0 1 1 1 0 0;... % 1 1 0 0 0 0 0 0])); % mmopentransf( f, 'city-block') % mmopentransf( f, 'chessboard') % mmopentransf( f, 'linear-h') % mmopentransf( f, 'linear-v') % % f=imread('numbers.tif'); % mmshow(f); % g=mmopentransf(f,'OCTAGON'); % mmshow(g); % % % % THE OPEN TRANSFORM STORES ALL THE OPENINGS BY THE DISK WITH RADIUS % R % b=mmsedisk(3,'2D','OCTAGON'); % g1=mmopen(f,b); % mmshow(g1); % g2=mmcmp(g,'>',3); % mmis(g1,'==',g2) % % See also MMOPEN, MMPATSPEC, MMSEDISK. % begin of the default argument automatic treatment if ~exist('type','var') type = 'OCTAGON'; end if ~exist('n','var') n = 65535; end % end of the default argument automatic treatment 1 if (nargin == 0 | nargin > 3) disp('Error: 1, 2 or 3 input parameters'); return; end if ~mmisbinary(f) disp('Error: input image is not binary'); return; end type = upper(type); if (strcmp(type,'OCTAGON') | ... strcmp(type,'CHESSBOARD') | ... strcmp(type,'CITY-BLOCK') ) flag = 0; elseif strcmp(type,'LINEAR-H') se = mmimg2se(logical(uint8([1 1 1]))); flag = 1; elseif strcmp(type,'LINEAR-V') se = mmimg2se(logical(uint8([1;1;1]))); flag = 1; else disp('Error: only accepts OCTAGON, CHESSBOARD, CITY-BLOCK, LINEAR-H, or LINEAR-V as type'); return; end k=0; y=uint16(zeros(size(f))); a=logical(uint8(1)); z=logical(uint8(0)); while ~(mmisequal(a,z) | (k>=n)) fprintf('\rprocessing r=%3.0f',k); if flag a=mmopen(f,mmsesum(se,k)); else a=mmopen(f,mmsedisk(k,'2D',type)); end y=mmaddm(y, mmgray(a,'uint16',1)); k=k+1; end fprintf('\n'); % Copyright (c) 1998-2001 by SDC Information Systems.