Image Processing Toolbox User's Guide |
Pixel Connectivity
Morphological processing starts at the peaks in the marker image and spreads throughout the rest of the image based on the connectivity of the pixels. Connectivity defines which pixels are connected to other pixels. A set of pixels in a binary image that form a connected group is called an object or a connected component.
For example, this binary image contains one foreground object--all the pixels that are set to 1
. If the foreground is 4-connected, the image has one background object, and all the pixels are set to 0
. However, if the foreground is 8-connected, the foreground makes a closed loop and the image has two separate background objects: the pixels in the loop and the pixels outside the loop.
0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Defining Connectivity in an Image
The following table lists all the standard two- and three-dimensional connectivities supported by the toolbox. See these sections for more information:
Supported ConnectivitiesChoosing a Connectivity
The type of neighborhood you choose affects the number of objects found in an image and the boundaries of those objects. For this reason, the results of many morphology operations often differ depending upon the type of connectivity you specify.
For example, if you specify a 4-connected neighborhood, this binary image contains two objects; if you specify an 8-connected neighborhood, the image has one object.
Specifying Custom Connectivities
You can also define custom neighborhoods by specifying a 3-by-3-by-...-by-3 array of 0's and 1's. The 1
-valued elements define the connectivity of the neighborhood relative to the center element.
For example, this array defines a "North/South" connectivity that has the effect of breaking up an image into independent columns.
Note Connectivity arrays must be symmetric about their center element. Also, you can use a 2-D connectivity array with a 3-D image; the connectivity affects each "page" in the 3-D image. |
Marker and Mask | Flood-Fill Operations |
© 1994-2005 The MathWorks, Inc.