function y = mmcmp( f1, oper, f2, oper1, f3 ) % MMCMP Compare two images pixelwisely. % % Y = MMCMP( F1, OPER, F2, OPER1, F3 ) % % Input: % F1 - Gray-scale (uint8 or uint16) or binary image (logical uint8). % OPER - String. relationship from: '==', '~=', '<','<=', '>', '>='. % F2 - Gray-scale (uint8 or uint16) or binary image (logical uint8). % OPER1 - String. relationship from: '==', '~=', '<','<=', '>', '>= % '. DEFAULT: No parameter. % F3 - Gray-scale (uint8 or uint16) or binary image (logical uint8). % DEFAULT: No parameter. % % Output: % Y - Binary image (logical uint8). % % Apply the relation OPER to each pixel of images F1 and F2, the % result is a binary image with the same size. Optionally, it is % possible to make the comparison among three image. It is possible % to use a constant value in place of any image, in this case the % constant is treated as an image of the same size as the others % with all pixels with the value of the constant. % % Examples % -------- % % mmcmp(uint8([1 2 3]),'<', uint8(2)) % mmcmp(uint8([1 2 3]),'<', uint8([0 2 4])) % mmcmp(uint8([1 2 3]),'==',uint8([1 1 3])) % % % f=mmreadgray('keyb.tif'); % fbin=mmcmp(uint8(10),'<', f, '<', uint8(50)); % mmshow(f); % mmshow(fbin); % % % See also MMFREEDOM, MMIS, MMTHRESHAD. % begin of the default argument automatic treatment % end of the default argument automatic treatment 1 if nargin<3 disp('Error: mmcmp requires at least 3 arguments'); return; elseif (nargin==3) | (nargin==5) if strcmp('==',oper) y= mmthreshad(f1,f2,f2); elseif strcmp('~=',oper) y= mmneg(mmthreshad(f1,f2,f2)); elseif strcmp('<=',oper) y= mmthreshad(f2,f1); elseif strcmp('>=',oper) y= mmthreshad(f1,f2); elseif strcmp('>',oper) y= mmneg(mmthreshad(f2,f1)); elseif strcmp('<',oper) y= mmneg(mmthreshad(f1,f2)); else disp('Error: oper must be one of: ==, ~=, >, >=, <, <='); end if nargin == 5 if strcmp('==',oper1) y =mmintersec(y, mmthreshad(f2,f3,f3)); elseif strcmp('~=',oper1) y= mmintersec(y, mmneg(mmthreshad(f2,f3,f3))); elseif strcmp('<=',oper1) y= mmintersec(y, mmthreshad(f3,f2)); elseif strcmp('>=',oper1) y= mmintersec(y, mmthreshad(f2,f3)); elseif strcmp('>',oper1) y= mmintersec(y, mmneg(mmthreshad(f3,f2))); elseif strcmp('<',oper1) y= mmintersec(y, mmneg(mmthreshad(f2,f3))); else disp('Error: oper1 must be one of: ==, ~=, >, >=, <, <='); end end elseif nargin==4 disp('Error: mmis requires 3 or 5 args'); else disp('Error: mmis requires 3 or 5 args'); end % Copyright (c) 1998-2001 by SDC Information Systems.