_props_to_dict(regions, properties=('label', 'bbox'), separator='-')
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.
List of RegionProperties objects as returned by regionprops
.
Properties 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.
For 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
, and inertia_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, image
and coords
.
Dictionary mapping property names to an array of values of that property, one value per region. This dictionary can be used as input to pandas DataFrame
to map property names to columns in the frame and regions to rows.
Convert image region properties list into a column dictionary.
>>> from skimage import data, util, measure
... image = data.coins()
... label_image = measure.label(image > 110, connectivity=image.ndim)
... proplist = regionprops(label_image, image)
... props = _props_to_dict(proplist, properties=['label', 'inertia_tensor',
... 'inertia_tensor_eigvals'])
... props # doctest: +ELLIPSIS +SKIP {'label': array([ 1, 2, ...]), ... 'inertia_tensor-0-0': array([ 4.012...e+03, 8.51..., ...]), ... ..., 'inertia_tensor_eigvals-1': array([ 2.67...e+02, 2.83..., ...])}
The resulting dictionary can be directly passed to pandas, if installed, to obtain a clean DataFrame:
This example is valid syntax, but we were not able to check execution>>> import pandas as pd # doctest: +SKIPSee :
... data = pd.DataFrame(props) # doctest: +SKIP
... data.head() # doctest: +SKIP label inertia_tensor-0-0 ... inertia_tensor_eigvals-1 0 1 4012.909888 ... 267.065503 1 2 8.514739 ... 2.834806 2 3 0.666667 ... 0.000000 3 4 0.000000 ... 0.000000 4 5 0.222222 ... 0.111111
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.measure._regionprops._props_to_dict
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them