This is a development version (0.26.1rc0.dev0) and may be unstable.Go to latest (0.26.1rc0.dev0+git20260530.b607368ff)
{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0 / skimage / measure / _regionprops / regionprops

function

skimage.measure._regionprops:regionprops

source: /_skimage2/measure/_regionprops.py:1164

Signature

def regionprops(label_image, intensity_image = None, cache = True, *, extra_properties = None, spacing = None, offset = None)

Summary

Measure properties of labeled image regions.

Extended Summary

Region properties are evaluated on demand and come in diverse types. If you want to do tabular data analysis of specific properties, consider using skimage.measure.regionprops_table instead.

Parameters

label_image : (M, N[, P]) ndarray

Label image. Labels with value 0 are ignored.

intensity_image : (M, N[, P][, C]) ndarray, optional

Intensity (input) image of same shape as label image, plus optionally an extra dimension for multichannel data. Currently, this extra channel dimension, if present, must be the last axis. Default is None.

cache : bool, optional

Determine whether to cache calculated properties. The computation is much faster for cached properties, whereas the memory consumption increases.

extra_properties : iterable of callables

Add extra property computation functions that are not included with skimage. The name of the property is derived from the function name and its dtype is inferred by calling the function on a small sample. If the name of an extra property clashes with the name of an existing property, the extra property will not be visible and a UserWarning will be issued. A property computation function must take label_image as its first argument. If the property requires an intensity image, it must accept intensity_image as the second argument.

spacing : tuple of float, shape (ndim,)

The pixel spacing along each axis of the image.

offset : array-like of int, shape `(label_image.ndim,)`, optional

Coordinates of the origin ("top-left" corner) of the label image. Normally this is ([0, ]0, 0), but it might be different if one wants to obtain regionprops of subvolumes within a larger volume.

Returns

properties : list of RegionProperties

Each item of the list corresponds to one labeled image region, and can be accessed using the attributes listed below.

Notes

The following properties can be accessed as attributes or keys:

area

Area of the region, i.e., number of pixels of the region scaled by pixel area (as determined by spacing).

area_bbox

Area of the bounding box, i.e., number of pixels of the region's bounding box scaled by pixel area (as determined by spacing).

area_convex

Area of the convex hull image, which is the smallest convex polygon that encloses the region.

area_filled

Area of the region with all the holes filled in.

axis_major_length

The length of the major axis of the ellipse that has the same normalized second central moments as the region.

axis_minor_length

The length of the minor axis of the ellipse that has the same normalized second central moments as the region.

bbox

Bounding box (min_row, min_col, max_row, max_col). Pixels belonging to the bounding box are in the half-open interval [min_row; max_row) and [min_col; max_col).

centroid

Centroid coordinate tuple (row, col).

centroid_local

Centroid coordinate tuple (row, col), relative to region bounding box.

centroid_weighted

Centroid coordinate tuple (row, col) weighted with intensity image.

centroid_weighted_local

Centroid coordinate tuple (row, col), relative to region bounding box, weighted with intensity image.

coords_scaled

Coordinate list (row, col) of the region scaled by spacing.

coords

Coordinate list (row, col) of the region.

eccentricity

Eccentricity of the ellipse that has the same second moments as the region. The eccentricity is the ratio of the focal distance (distance between focal points) over the major axis length. The value is in the interval [0, 1). When it is 0, the ellipse becomes a circle.

equivalent_diameter_area

The diameter of a circle with the same area as the region.

euler_number

Euler characteristic of the set of non-zero pixels. Computed as number of connected components subtracted by number of holes (input.ndim connectivity). In 3D, number of connected components plus number of holes subtracted by number of tunnels.

extent

Ratio of pixels in the region to pixels in the total bounding box. Computed as area / (rows * cols).

feret_diameter_max

Maximum Feret's diameter computed as the longest distance between points around a region's convex hull contour as determined by find_contours [5].

image

Binary region image sliced by the bounding box.

image_convex

Binary convex hull image sliced by bounding box.

image_filled

Binary region image with filled holes sliced by bounding box.

image_intensity

Intensity image sliced by bounding box.

inertia_tensor

Inertia tensor of the region for the rotation around its mass.

inertia_tensor_eigvals

The eigenvalues of the inertia tensor in decreasing order.

intensity_max

Value of greatest intensity in the region.

intensity_mean

Average of intensity values in the region.

intensity_median

Value of median intensity in the region.

intensity_min

Value of lowest intensity in the region.

intensity_std

Standard deviation of intensity values in the region.

label

The region's label in the input label image.

moments

Spatial moments up to 3rd order

m_ij = sum{ array(row, col) * row^i * col^j }

where the sum is over the row, col coordinates of the region.

moments_central

Central moments (translation invariant) up to 3rd order

mu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }

where the sum is over the row, col coordinates of the region, and row_c and col_c are the coordinates of the region's centroid.

moments_hu

Hu moments (translation, scale and rotation invariant).

moments_normalized

Normalized moments (translation and scale invariant) up to 3rd order

nu_ij = mu_ij / m_00^[(i+j)/2 + 1]

where m_00 is the zeroth spatial moment.

moments_weighted

Spatial moments of intensity image up to 3rd order

wm_ij = sum{ array(row, col) * row^i * col^j }

where the sum is over the row, col coordinates of the region.

moments_weighted_central

Central moments (translation invariant) of intensity image up to 3rd order

wmu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }

where the sum is over the row, col coordinates of the region, and row_c and col_c are the coordinates of the region's weighted centroid.

moments_weighted_hu

Hu moments (translation, scale and rotation invariant) of intensity image.

moments_weighted_normalized

Normalized moments (translation and scale invariant) of intensity image up to 3rd order

wnu_ij = wmu_ij / wm_00^[(i+j)/2 + 1]

where wm_00 is the zero-th spatial moment (intensity-weighted area).

num_pixels

Number of foreground pixels.

orientation

Angle between the 0th axis (rows) and the major axis of the ellipse that has the same second moments as the region, ranging from to counter-clockwise.

perimeter

Perimeter of the region which approximates the contour as a line through the centers of border pixels using a 4-connectivity.

perimeter_crofton

Perimeter of the region approximated by the Crofton formula in 4 directions.

slice

A slice to extract the region from the input image.

solidity

Ratio of pixels in the region to pixels of the convex hull image.

properties also supports iteration, so that you can do

for region in properties:
    print(region, properties[region])

Examples

import skimage as ski
img = ski.util.img_as_ubyte(ski.data.coins()) > 110
label_img = ski.measure.label(img, connectivity=img.ndim)
props = ski.measure.regionprops(label_img)
✓
props[0].centroid
props[0]['centroid']
✗
(np.float64(22.72987986048314), np.float64(81.91228523446583))
Add custom measurements by passing functions as ``extra_properties``:
import numpy as np
import skimage as ski
img = ski.util.img_as_ubyte(ski.data.coins()) > 110
label_img = ski.measure.label(img, connectivity=img.ndim)
def pixelcount(regionmask):
    return np.sum(regionmask)
props = ski.measure.regionprops(label_img, extra_properties=(pixelcount,))
✓
props[0].pixelcount
props[1]['pixelcount']
✗
np.int64(42)

See also

label

Aliases

  • skimage.measure.regionprops

Referenced by