bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / measure / _regionprops / regionprops_table
function
skimage.measure._regionprops:regionprops_table
source: /dev/scikit-image/src/skimage/measure/_regionprops.py :974
Signature
def regionprops_table ( label_image , intensity_image = None , properties = ('label', 'bbox') , * , cache = True , separator = - , extra_properties = None , spacing = None ) Summary
Compute region properties and return them as a pandas-compatible table.
Extended Summary
The return value is a dictionary mapping property names to value arrays. This dictionary can be used as input to pandas.DataFrame to result in a "tidy" [1] table with one region per row and one property per column.
Use this function typically when you want to do downstream data analysis, or save region data to disk in a structured way. One downside of this function is that it breaks multi-dimensional properties into independent columns; for example, the region centroids of a 3D image end up in three different columns, one per dimension. If you need to do complex computations with the region properties, using skimage.measure.regionprops might be more fitting.
Parameters
label_image: (M, N[, P]) ndarrayLabel image. Labels with value 0 are ignored.
intensity_image: (M, N[, P][, C]) ndarray, optionalIntensity (input) image of same shape as label image, plus optionally an extra dimension for multichannel data. The channel dimension, if present, must be the last axis. Default is None.
properties: tuple or list of str, optionalProperties that will be included in the resulting dictionary For a list of available properties, please see regionprops. Users should remember to add "label" to keep track of region identities.
cache: bool, optionalDetermine whether to cache calculated properties. The computation is much faster for cached properties, whereas the memory consumption increases.
separator: str, optionalFor non-scalar properties not listed in OBJECT_COLUMNS, each element will appear in its own column, with the index of that element separated from the property name by this separator. For example, the inertia tensor of a 2D region will appear in four columns:
inertia_tensor-0-0,inertia_tensor-0-1,inertia_tensor-1-0, andinertia_tensor-1-1(where the separator is-).Object columns are those that cannot be split in this way because the number of columns would change depending on the object. For example,
imageandcoords.extra_properties: iterable of callablesAdd extra property computation functions that are not included with skimage. The name of the property is derived from the function name, the 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 is issued. A property computation function must take a region mask as its first argument. If the property requires an intensity image, it must accept the intensity image as the second argument.
spacing: tuple of float, shape (ndim,)The pixel spacing along each axis of the image.
Returns
out_dict: dictDictionary mapping property names to an array of values of that property, one value per region. This dictionary can be used as input to pandas
DataFrameto map property names to columns in the frame and regions to rows. If the image has no regions, the arrays will have length 0, but the correct type.
Notes
Each column contains either a scalar property, an object property, or an element in a multidimensional array.
Properties with scalar values for each region, such as "eccentricity", will appear as a float or int array with that property name as key.
Multidimensional properties of fixed size for a given image dimension, such as "centroid" (every centroid will have three elements in a 3D image, no matter the region size), will be split into that many columns, with the name {property_name}{separator}{element_num} (for 1D properties), {property_name}{separator}{elem_num0}{separator}{elem_num1} (for 2D properties), and so on.
For multidimensional properties that don't have a fixed size, such as "image" (the image of a region varies in size depending on the region size), an object array will be used, with the corresponding property name as the key.
Examples
from skimage import data, util, measure image = data.coins() label_image = measure.label(image > 110, connectivity=image.ndim) props = measure.regionprops_table(label_image, image, properties=['label', 'inertia_tensor', 'inertia_tensor_eigvals'])✓
from skimage import data, util, measure import numpy as np def quartiles(regionmask, intensity): return np.percentile(intensity[regionmask], q=(25, 50, 75)) image = data.coins() label_image = measure.label(image > 110, connectivity=image.ndim) props = measure.regionprops_table(label_image, intensity_image=image, properties=('label',), extra_properties=(quartiles,))✓
Aliases
-
skimage.measure.regionprops_table