PERIMETER Function (PV-WAVE Extreme Advantage)
Computes the perimeter of a region in an image.
Usage
result = PERIMETER(image, region)
Input Parameters
image—A 2D array.
region—A long array containing the pixel element numbers in image that compose the region.
Returned Value
result—A long scalar value, in units of pixels, that is the perimeter of the region.
Keywords
None.
Discussion
The perimeter of a region is defined as the number of pixels in its boundary. The boundary of a specified region in image is computed by considering the 8-neighbors of every pixel in image. Any pixel having an 8-neighbor that is not a member of the region is marked as a boundary pixel. The total number of boundary pixels in the image is the region perimeter.
Example
; Read an image.
image = IMAGE_READ(!IP_Data + 'blobs.tif')
; Threshold the image for a single blob.
thresh_image = THRESHOLD(image('pixels'), 20, 30, /Binary)
; Find the pixel number of the object.
region = WHERE(thresh_image EQ 255)
; Calculate the perimeter and print it to the screen.
perim = PERIMETER(thresh_image, region)
PRINT, perim
See Also