REGION_STATS Function (PV-WAVE Extreme Advantage)

Performs several statistical calculations on specified regions in an image.

Usage

result = REGION_STATS(image[, region_image])

Input Parameters

image—An image with binary regions. This parameter must be a byte array data type, if region_image is not given.

region_image—(optional) A 2D byte array with binary regions. This parameter is used as a mask to identify the pixels that compose each region in image.

Returned Value

result—A 2D double array of statistics with dimensions 11-by-n_regions, where n_regions is the number of regions for which the statistics are computed. The 11 statistics of the regions in image are as follows:

area—The number of pixels in the region.

mean—The average of pixels in the region.

min—The minimum pixel value in the region.

max—The maximum pixel value in the region.

stdev—The standard deviation of the pixel values in the region.

mode—The most frequent pixel value in the region.

range—The difference between the minimum and the maximum value in the region.

perimeter—The distance around the border of the region in pixels.

compactness—A measure of the compactness of the region. Defined as the perimeter squared over the area.

major axis angle—The angle of the major axis through the region. The major axis is directed in the area of maximal region dispersion.

centroid—The centroid of the region, given as the element number in the image.

Keywords

Region_Values—A 1D byte array specifying the regions in  image or region_image for which to compute statistics. (Default: all regions in  image or region_image)

Discussion

Statistical measures on regions within an image provide valuable quantitative descriptions of segmented objects. The statistical measures performed by the REGION_STATS function for each region value, i, are defined as follows:

Areai = N, where N is the number of elements in region_image equal to i.

Meani = TOTAL(x)/N, where N is the number of elements in region_image equal to i, and x is the subset of pixels in image where region_image is equal to i.

Mini = MIN(x), where x is the subset of pixels in image where region_image is equal to i.

Maxi = MAX(x), where x is the subset of pixels in image where region_image is equal to i.

Stdevi = STDEV(x), where x is the subset of pixels in image where region_image is equal to i.

Modei = MODE(x), where x is the subset of pixels in image where region_image is equal to i.

Rangei = RANGE(x), where x is the subset of pixels in image where region_image is equal to i.

Perimeteri = PERIMETER(x, e), where x is the subset of pixels in image where region_image is equal to i, and e is an array of the element numbers in region_image that are equal to i.

Compactnessi = [PERIMETER(x, e)*PERIMETER(x, e)]/Areai, where x is the subset of pixels in image where region_image is equal to i, and e is an array of the element numbers in region_image that are equal to i.

Major Axisi = MAJOR_AXIS(x, e), where x is the subset of pixels in image where region_image is equal to i, and e is an array of the element numbers in region_image that are equal to i.

Centroidi = CENTROID(x, e), where x is the subset of pixels in image where region_image is equal to i, and e is an array of the element numbers in region_image that are equal to i.

Example

; Read an image.
knee = IMAGE_READ(!IP_Data + 'sagknee.tif')
; Find regions in image using K-mean segmentation. Choose random
; points for the cluster seeds.
cluster_seeds = [20, 30, 500, 1000, 2000]
region_image = IPCLUSTER(knee('pixels'), $
cluster_seeds, Fill_Values = [1, 2, 3, 4, 5])
; Compute the statistics of the original image pixels underlying
; the identified regions.
result = REGION_STATS(knee('pixels'), region_image)
; View the statistics for each region.
PRINT, result

See Also

CENTROID, IPCLUSTER, MAJOR_AXIS, MODE, PERIMETER, RANGE, REGION_COUNT, REGION_FIND, REGION_GROW