LABEL_REGION
Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also
The LABEL_REGION function consecutively labels all of the regions, or blobs, of a bi-level image with a unique region index. This process is sometimes called "blob coloring". A region is a set of non-zero pixels within a neighborhood around the pixel under examination.
The argument for LABEL_REGION is an n-dimensional bi-level integer type array—only zero and non-zero values are considered.
Statistics on each of the regions may be easily calculated using the HISTOGRAM function as shown in the examples below.
Syntax
Result = LABEL_REGION( Data [, /ALL_NEIGHBORS] [, /ULONG] )
Return Value
The result of the function is an integer array of the same dimensions with each pixel containing its region index. A region index of zero indicates that the original pixel was zero and belongs to no region. Output values range from 0 to the number of regions.
Arguments
Data
A n-dimensional image to be labeled. Data is converted to integer type if necessary. Pixels at the edges of Data are considered to be zero.
Keywords
ALL_NEIGHBORS
Set this keyword to indicate that all adjacent neighbors to a given pixel should be searched. (This is sometimes called 8-neighbor searching when the image is 2-dimensional). The default is to search only the neighbors that are exactly one unit in distance from the current pixel (sometimes called 4-neighbor searching when the image is 2-dimensional).
ULONG
Set this keyword to specify that the output array should be an unsigned long integer.
Examples
Note
Also see Analyzing Image Shapes (Image Processing in IDL).
Example 1
This example counts the number of distinct regions within an image, and their population. Note that region 0 is the set of zero pixels that are not within a region:
Example 2
This example also prints the average value and standard deviation of each region:
Version History
For more information on deprecated features, see IDL API History.
See Also
ANNOTATE, DEFROI, HISTOGRAM, SEARCH2D