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

mmgdist - Geodesic Distance Transform.


Synopsis
y = mmgdist( f, g, Bc, METRIC )
Input
f: Binary image (logical uint8).
g: Binary image (logical uint8). Marker image
Bc: Structuring element. (metric for distance). Default: Elementary cross (mmsecross).
METRIC: String. 'EUCLIDEAN' if specified. Default: No parameter.
 
Obs: f, g must have the same data type.
Output
y: Gray-scale (uint8 or uint16) image. uint16 (distance image).
Description
mmgdist creates the geodesic distance image y of the binary image f relative to the binary image g. The value of y at the pixel x is the length of the smallest path between x and f. The distances available are based on the Euclidean metrics and on metrics generated by a neighbourhood graph, that is characterized by a connectivity rule defined by the structuring element Bc. The connectivity for defining the paths is consistent with the metrics adopted to measure their length. In the case of the Euclidean distance, the space is considered continuos and, in the other cases, the connectivity is the one defined by Bc.
Limitation
To generate useful Distance transforms, the structuring elements must be symmetric and with the origin included. The Euclidean Distance transform is rounded to the nearest integer, since it is represented in an unsigned integer image. You should use the mmsebox structuring element when computing the Euclidean Distance transform.
Examples
f=mmbinary(uint8([...
 1 1 1 1 1 1;...
 1 1 1 0 0 1;...
 1 0 1 0 0 1;...
 1 0 1 1 0 0;...
 0 0 1 1 1 1;...
 0 0 0 1 1 1]));
g=mmbinary(uint8([...
 0 0 0 0 0 0;...
 1 1 0 0 0 0;...
 0 0 0 0 0 0;...
 0 0 0 0 0 0;...
 0 0 0 0 0 0;...
 0 0 0 0 0 1]));
y=mmgdist(f,g,mmsecross)

y =
           1           1           2           3           4           5
           0           0           1       65535       65535           6
           1       65535           2       65535       65535           7
           2       65535           3           4       65535       65535
       65535       65535           4           3           2           1
       65535       65535       65535           2           1           0
f=mmbinary(mmreadgray('maze_bw.tif'));
Warning: Converting image from binary uint8 to uint8.
g=mmintersec(f,0);
Warning: Converting image from scalar to binary uint8.
g=mmdraw(g,'FRECT:3,3,7,7:END');
y=mmgdist(f,g,mmsebox,'EUCLIDEAN');
mmshow(f,g);
mmdtshow(y,200);
image
(f,g)
image
(y,200)
Equation

geodesic distance function using structuring element:

equation

Algorithm
function y=mmgdist_equ(f,g,Bc)
  fneg = mmneg(f);
  gneg = mmneg(g);
  y = mmgray(gneg,'uint8',1);
  for i=1:255
     ero = mmcero(gneg,fneg,Bc,i);
     y = mmaddm(y,mmgray(ero,'uint8',1));
  end
See Also
mmcero - Erode an image conditionally.
mmdist - Distance transform.
mmfreedom - Control automatic data type conversion.
mmsebox - Create a box structuring element.
mmsecross - Cross structuring element.

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