DIST_MAP Function (PV-WAVE Extreme Advantage)

Computes the Euclidean distance map (EDM) for an image.

Usage

result = DIST_MAP(image[, threshold])

Input Parameters

image—Nonzero 2D or 3D byte array of any data type except string or complex. This array contains an image; or image, row, or pixel-interleaved images.

 

Note

The image parameter must be a binary image containing only two grayscale levels, if threshold is not given.

threshold—(optional) Specifies the threshold value for the object in image; the image object is assumed to be composed of pixels with values greater than or equal to threshold.

Returned Value

result—A double array of the same size and dimensions as image, containing the Euclidean distance map of image.

Keywords

Intleave—Scalar string indicating type of interleaving of 3D input 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.

ValueSpecifies a scalar value greater than 0 for the binary object in image.

Discussion

The Euclidean distance map is used to identify object boundaries. It is computed by finding the shortest distance from each object-pixel in image to a background pixel. The Euclidean distance is defined as follows:

 

where x = (xobjectxbackground) and y = (yobjectybackground) .

Example 1

; Read a binary image.
test_image = IMAGE_READ(!IP_Data + 'objects.tif')
; Find the Euclidean distance map (EDM) of the image.
edm_image = DIST_MAP(test_image('pixels'), 100)
; Threshold the EDM to find the object outlines.
thresh_image = THRESHOLD(edm_image, 0, 2, /A_Neq, /Binary)
; View the object outlines.
TVSCL, thresh_image

Example 2

The results of this example are shown in Test Blobs in Grayscale, Distance Map of a Blob, and Isolated Blob Outline.

; Read a binary image of different blob shapes.
test_image = IMAGE_READ(!IP_Data +'blobs.tif')
image = THRESHOLD(test_image('pixels'), 5, 250, /Binary)
; Find and fill the regions.
region_seeds = REGION_FIND(image, 255, 6)
region_image = REGION_GROW(image, region_seeds, 2.0)
TVSCL, region_image
; Find the EDM of a single region.
edm_image = DIST_MAP(region_image, value = 2)
TVSCL, edm_image
; Threshold the EDM to find region outline.
thresh_image = THRESHOLD(edm_image, 0, 2, /A_Neq, /Binary)
; View the object outlines.
TVSCL, thresh_image

 

Test Blobs in Grayscale

 

 

Distance Map of a Blob

 

 

Isolated Blob Outline

 

See Also

HIT_MISS, MORPH_CLOSE, MORPH_OPEN, MORPH_OUTLINE,  SKELETONIZE, TOP_HAT

In the PV‑WAVE Reference:  DILATE,  ERODE