[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] SDC Morphology Toolbox V1.1 15Jan02

mmtoggle - Image contrast enhancement or classification by the toggle operator.


Synopsis
y = mmtoggle( f, f1, f2, OPTION )
Input
f: Gray-scale (uint8 or uint16) image.
f1: Gray-scale (uint8 or uint16) image.
f2: Gray-scale (uint8 or uint16) image.
OPTION: String. 'BINARY' or 'GRAY'. Default: "GRAY".
 
Obs: f, f1, f2 must have the same data type.
Output
y: Gray-scale (uint8 or uint16) or binary image (logical uint8). binary image if option is 'BINARY' or same type as f
Description
mmtoggle creates the image y that is an enhancement or classification of the image f by the toggle operator, with parameters f1 and f2. If the OPTION is 'GRAY', it performs an enhancement and, if the OPTION is 'BINARY', it performs a binary classification. In the enhancement, a pixel takes the value of the corresponding pixel in f1 or f2, according to a minimum distance criteria from f to f1 or f to f2. In the classification, the pixels in f nearest to f1 receive the value 0 , while the ones nearest to f2 receive the value 1.
Limitation
f1 must be less or equal f and f must be less or equal f2.
Examples

Gray-scale option:

f = uint8([0 1 2 3 4 5 6]);
f1 = uint8([0 0 0 0 0 0 0]);
f2 = uint8([6 6 6 6 6 6 6]);
mmtoggle(f,f1,f2)

ans =
     0     0     0     6     6     6     6
a = mmreadgray('angiogr.tif');
b = mmero(a,mmsedisk(2));
c = mmdil(a,mmsedisk(2));
d = mmtoggle(a,b,c);
mmshow(a);
mmshow(d); 
image
(a)
image
(d)

Binary option:

e = mmreadgray('lenina.tif');
f = mmero(e,mmsedisk(2));
g = mmdil(e,mmsedisk(2));
h = mmtoggle(e,f,g,'BINARY');
mmshow(e);
mmshow(h); 
image
(e)
image
(h)
Equation

Gray-scale option

equation

Binary option

equation

Algorithm
function g = mmtoggle_equ(f,f1,f2,option)
  g=mmthreshad(mmsubm(f2,f),mmsubm(f,f1));
  if (strcmp(option,'gray'))
    t=mmgray(g);
    g=mmunion(mmintersec(mmneg(t),f1),mmintersec(t,f2));
  end
See Also
mmfreedom - Control automatic data type conversion.
mmthreshad - Threshold (adaptive).

[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] Valid XHTML 1.0!
Copyright (c) 1998-2002 by SDC Information Systems