{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / measure / _regionprops / regionprops

function

skimage.measure._regionprops:regionprops

source: /dev/scikit-image/src/skimage/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

area_bbox

area_bbox

area_convex

area_convex

area_filled

area_filled

axis_major_length

axis_major_length

axis_minor_length

axis_minor_length

bbox

bbox

centroid

centroid

centroid_local

centroid_local

centroid_weighted

centroid_weighted

centroid_weighted_local

centroid_weighted_local

coords_scaled

coords_scaled

coords

coords

eccentricity

eccentricity

equivalent_diameter_area

equivalent_diameter_area

euler_number

euler_number

extent

extent

feret_diameter_max

feret_diameter_max

image

image

image_convex

image_convex

image_filled

image_filled

image_intensity

image_intensity

inertia_tensor

inertia_tensor

inertia_tensor_eigvals

inertia_tensor_eigvals

intensity_max

intensity_max

intensity_mean

intensity_mean

intensity_median

intensity_median

intensity_min

intensity_min

intensity_std

intensity_std

label

label

moments

moments

moments_central

moments_central

moments_hu

moments_hu

moments_normalized

moments_normalized

moments_weighted

moments_weighted

moments_weighted_central

moments_weighted_central

moments_weighted_hu

moments_weighted_hu

moments_weighted_normalized

moments_weighted_normalized

num_pixels

num_pixels

orientation

orientation

perimeter

perimeter

perimeter_crofton

perimeter_crofton

slice

slice

solidity

solidity

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']
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']

See also

label

Aliases

  • skimage.measure.regionprops

Referenced by