TOP_HAT Function
Performs the morphologic top-hat transform for shape processing.
Usage
result = TOP_HAT(image, structure[, x0, y0])
Input Parameters
image—A 2D array.
structure—A 1D or 2D array containing the structuring element. The elements are interpreted as binary values (either zero of nonzero), unless the Gray keyword is used.
x0—(optional) The x-coordinate of the structuring element’s origin.
y0—(optional) The y-coordinate of the structuring element’s origin.
Returned Value
result—An array of the same size and dimensions as image containing the top-hat transformed image.
Keywords
Gray—If set, grayscale, rather than binary erosion is used.
Valley—If set, the valley detector top-hat transform is performed; otherwise, the peak detector transform is used.
Values—An array of the same dimensions and number of elements as structure containing the values of the structuring element.
Discussion
Morphological operations are defined for grayscale byte images. If image is not originally of type byte, PV‑WAVE makes a temporary copy of image that is of type byte before using it for the morphological processing.
The morphological top-hat transform is used to identify small pixel clusters and edges. The peak detection top-hat operator is defined as the original image minus the opened image. The valley detection top-hat operator is defined as the closed image minus the original image.
Example
; Make a square structuring element.
morph_struct = BYTARR(3, 3)
morph_struct(*) = 1B
morph_struct(1, 1) = 0B
; Read an image.
test_image = IMAGE_READ(!IP_Data + 'objects.tif')
; Perform the top-hat transform to find regional peaks.
tophat_image = TOP_HAT(test_image('pixels'), morph_struct)
TVSCL, tophat_image
See Also
In the PV‑WAVE Reference:  DILATE,  ERODE