REGION_MERGE Function (PV-WAVE Extreme Advantage)

Merges homogeneous regions in an image, where the homogeneity is based on the region average.

Usage

result = REGION_MERGE(image, max_n_regions[, threshold])

Input Parameters

imageA 2D or 3D array of any data type except string or complex that has homogeneous regions containing an image; image, row or pixel-interleaved images; or a volume.

max_n_regionsAn integer greater than 0 and less than 255, specifying the maximum number of regions for subdividing image.

threshold(optional) A floating-point scalar threshold value used to determine whether or not a pixel belongs to a given region. (Default: 0.1)

Returned Value

result—A 2D or 3D byte array containing filled regions.

Keywords

Fill_Mean—If set, each region is filled with the mean of the image pixels in the region.

Fill_Values—A byte array of values used to fill the regions which were merged, where the values are 0 < Fill_Valuesi < 255. The number of values in Fill_Values is {1, ..., max_n_regions}.

Intleave—A scalar string indicating the type of interleaving of 3D image arrays. Valid strings and the corresponding interleaving methods are:

'pixel'—The input array arrangement is (pxy) for p  pixel-interleaved images of x-by-y.

'row'—The 3D image array arrangement is (xpy) for p  row-interleaved images of x-by-y.

'image'—The 3D image array arrangement is (xyp) for p  image-interleaved images of x-by-y.

'volume'—The input image array is treated as a single entity.

Discussion

The algorithm for REGION_MERGE analyzes each pixel in the image and attempts to add it to a region. The pixel may be added to a region, if its value does not change region average by more than the threshold.

The REGION_MERGE function is useful for image segmentation and object identification and counting. This function can be used in place of, or in conjunction with, the REGION_GROW function. When the region seed points needed for the REGION_GROW function are unknown, the REGION_MERGE function should be used instead.

When using REGION_MERGE in conjunction with REGION_GROW, use the REGION_GROW function first, making sure that the Fill_Mean keyword is set. Then, to reduce the number of regions grown, apply REGION_MERGE with an appropriate threshold value.

Example 1

; Find separate regions using merging technique.
image = IMAGE_READ(!IP_Data + 'sagknee.tif')
region_image = REGION_MERGE(image('pixels'), 254, 2.0)
; Count the number of objects.
n_regions = REGION_COUNT(region_image)
TEK_COLOR
TVSCL, region_image

Example 2

image = IMAGE_READ(!IP_Data + 'sagknee.tif')
; Count the number of individual regions.
region_image = REGION_GROW(image('pixels'), region_seeds, 0.5)
n_regions = REGION_COUNT(region_image)
; Fill the regions with their means.
region_image = REGION_GROW(image('pixels'), $
region_seeds, 0.5, /Fill_Mean)
merge_image = REGION_MERGE(region_image, n_regions, 2.0)
TEK_COLOR
TVSCL, merge_image

See Also

IPCLUSTER,  REGION_GROW,  REGION_SPLIT, THRESH_ADAP, THRESHOLD