Attribute Catalog¶
This catalog lists the scalar attributes exposed through
mtlearn.morphology.AttributeType and the groups exposed through
mtlearn.morphology.AttributeGroup: 133 scalar attributes and nine groups.
Names, groups, and definitions follow the
mmcfilters v5.2.0 attribute catalog.
Attributes are computed per morphology-tree node slot. They are not image arrays. The usual result layout is:
attribute_index, values = morphology.compute_attributes(tree, attributes)
column = attribute_index["AREA"]
area_by_node_slot = values[:, column]
Attribute buffers default to np.float32. Pass dtype=np.float64 to
compute_attributes or compute_single_attribute when double-precision
attribute values are needed. Deterministic attribute filters accept both
float32 and float64 attribute vectors.
Use tree.num_internal_node_slots when allocating criteria, scores, or any
node-indexed array that will be passed back to filtering code.
Terminology¶
A morphology tree represents connected components or shapes by tree nodes. The proper part of a node is the set of image pixels assigned directly to that node. Each pixel belongs to one proper part and is identified by its row-major linear index. Attribute vectors are indexed by tree nodes.
A node slot is the dense integer row used internally for one internal tree node. Attribute arrays keep one row per slot so the same id can be reused by filters, scores, and reconstruction code. In ordinary trees these slots correspond to live internal nodes; after advanced topology edits, some slots may be kept for stable indexing.
The support of a node is the set of image pixels represented by that node: the pixels directly owned by the node plus the pixels represented by its descendant nodes. In a max-tree or min-tree, this support is the connected component associated with that tree node at its altitude.
Attribute Groups¶
Groups are convenience requests. They expand to canonical scalar attributes
before computation or CFP parameter construction. Each scalar is listed once
below, with its group memberships. ALL includes every listed scalar.
Group |
Meaning |
|---|---|
|
Node valuation, gray-level mass, contrast, height, mean, and variance. |
|
Size, bounding box, moment, bitquad, contour, and selected shape descriptors. |
|
Central moments, Hu invariants, and moment-derived descriptors. |
|
Bitquad and contour descriptors. |
|
Parent/child hierarchy descriptors. |
|
Descriptors of the approximate contour-distance field. |
|
Descriptors of the exact Euclidean contour-distance field. |
|
Geometry of the region enclosed by the external boundary, including holes. |
|
Every public scalar attribute. |
shape_attributes = morphology.expand_attribute_group(
morphology.AttributeGroup.SHAPE,
)
Contracts¶
The catalog uses three contracts:
Contract |
Meaning |
|---|---|
Altitude-aware |
Reads node altitude or gray-level values from a valued tree. |
Topology/support |
Uses node support, pixel coordinates, contours, or adjacency information. |
Tree topology |
Reads only parent/child relations in the hierarchy. |
Gray-Level Attributes¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Altitude-aware |
Node valuation: the gray level associated with the node. |
|
|
Altitude-aware |
Sum of altitude-weighted support contributions over the node subtree. |
|
|
Altitude-aware |
Recursive contrast volume |
|
|
Altitude-aware |
Maximum absolute altitude difference between the node and any node in its subtree. |
|
|
Altitude-aware |
Arithmetic mean of the image values over the full node support: |
|
|
Altitude-aware |
Population variance of the image values over the full node support, with denominator |
Gray-level attributes are good choices when the filter should depend on contrast, intensity, or altitude differences rather than pure geometry.
Size and Bounding-Box Attributes¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Number of pixels in the full node support. |
|
|
Topology/support |
Width, in columns, of the smallest axis-aligned bounding box enclosing the node support. |
|
|
Topology/support |
Height, in rows, of the smallest axis-aligned bounding box enclosing the node support. |
|
|
Topology/support |
Euclidean diagonal length of the bounding box, |
|
|
Topology/support |
Ratio |
|
|
Topology/support |
Bounding-box aspect ratio, |
|
|
Topology/support |
Minimum image column index covered by the node support. |
|
|
Topology/support |
Maximum image column index covered by the node support. |
|
|
Topology/support |
Minimum image row index covered by the node support. |
|
|
Topology/support |
Maximum image row index covered by the node support. |
Distance-Transform Attributes¶
These attributes describe distances from support pixels to the foreground
4-connected contour. Contour pixels have distance zero. DIST_TRANSF uses the
approximate field; DIST_TRANSF_EXACT uses exact Euclidean distances.
MAX_DIST is measured in pixels and equals the square root of
MAX_SQUARED_DIST, which is measured in squared pixels. The same relation
holds for MAX_DIST_EXACT and MAX_SQUARED_DIST_EXACT.
Approximate Distances¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Maximum of the approximate distance field, in pixels. |
|
|
Topology/support |
Maximum approximate squared contour-distance cost, in squared pixels. |
|
|
Topology/support |
Sum of the approximate squared-distance field over the node support. |
|
|
Topology/support |
Arithmetic mean of the approximate squared-distance field over the node support. |
|
|
Topology/support |
Square root of the mean approximate squared contour distance, in pixels. |
|
|
Topology/support |
Population variance of the approximate squared-distance samples. |
|
|
Topology/support |
Zero-based row of a support pixel attaining the approximate maximum; ties select the smallest row-major pixel. |
|
|
Topology/support |
Zero-based column of the same deterministic approximate maximum-distance center. |
|
|
Topology/support |
Number of support pixels attaining the approximate maximum. |
|
|
Topology/support |
Arithmetic mean of row coordinates over the approximate maximum plateau. |
|
|
Topology/support |
Arithmetic mean of column coordinates over the approximate maximum plateau. |
|
|
Topology/support |
Sum of approximate Euclidean contour distances over the node support, in accumulated pixel units. |
|
|
Topology/support |
Arithmetic mean of Euclidean distances over the approximate field, in pixels. |
|
|
Topology/support |
Population variance of approximate Euclidean contour distances, in squared pixels. |
|
|
Topology/support |
Lower empirical median of the approximate Euclidean-distance field. |
|
|
Topology/support |
Most frequent approximate Euclidean distance; ties select the smallest distance. |
|
|
Topology/support |
Lower empirical 25th percentile of the approximate Euclidean-distance field. |
|
|
Topology/support |
Lower empirical 75th percentile of the approximate Euclidean-distance field. |
|
|
Topology/support |
Lower empirical 90th percentile of the approximate Euclidean-distance field. |
|
|
Topology/support |
Shannon entropy in bits of the normalized approximate squared-distance histogram. |
|
|
Topology/support |
Number of support pixels whose approximate squared-distance cost is positive. |
|
|
Topology/support |
Number of represented approximate squared-distance levels, including zero. |
|
|
Topology/support |
Zero-based row centroid weighted by approximate Euclidean distance. All-zero fields use the ordinary support centroid. |
|
|
Topology/support |
Zero-based column centroid weighted by approximate Euclidean distance. All-zero fields use the ordinary support centroid. |
|
|
Topology/support |
Unnormalized approximate distance-weighted central column moment. |
|
|
Topology/support |
Unnormalized approximate distance-weighted central row moment. |
|
|
Topology/support |
Unnormalized approximate distance-weighted mixed row-column moment. |
|
|
Topology/support |
Principal axis of the approximate distance-weighted second moments, in degrees; isotropic fields return zero. |
|
|
Topology/support |
Major/minor eigenvalue ratio of the approximate distance-weighted second moments, capped at |
Exact Distances¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Maximum exact Euclidean distance, in pixels, from a support pixel to the foreground 4-connected contour. |
|
|
Topology/support |
Maximum exact squared Euclidean contour distance, in squared pixels. |
|
|
Topology/support |
Sum of the exact squared Euclidean distance to the foreground A4 contour over every support pixel. |
|
|
Topology/support |
Arithmetic mean of the exact squared contour-distance field over the node support. |
|
|
Topology/support |
Root mean square Euclidean contour distance, |
|
|
Topology/support |
Population variance of the exact squared contour-distance samples, |
|
|
Topology/support |
Zero-based row of a support pixel attaining |
|
|
Topology/support |
Zero-based column of the same deterministic exact maximum-distance center. |
|
|
Topology/support |
Number of support pixels attaining the exact maximum squared contour distance. |
|
|
Topology/support |
Arithmetic mean of the row coordinates over the exact maximum-distance plateau. |
|
|
Topology/support |
Arithmetic mean of the column coordinates over the exact maximum-distance plateau. |
|
|
Topology/support |
Sum of exact Euclidean contour distances over the support, in accumulated pixel units. |
|
|
Topology/support |
Arithmetic mean of exact Euclidean contour distances, in pixels. |
|
|
Topology/support |
Population variance of exact Euclidean contour distances, in squared pixels. |
|
|
Topology/support |
Lower empirical median of the exact Euclidean-distance field. |
|
|
Topology/support |
Most frequent exact Euclidean distance; ties select the smallest distance. |
|
|
Topology/support |
Lower empirical 25th percentile of the exact Euclidean-distance field. |
|
|
Topology/support |
Lower empirical 75th percentile of the exact Euclidean-distance field. |
|
|
Topology/support |
Lower empirical 90th percentile of the exact Euclidean-distance field. |
|
|
Topology/support |
Shannon entropy in bits of the normalized exact squared-distance histogram. |
|
|
Topology/support |
Number of support pixels whose exact squared contour distance is positive. |
|
|
Topology/support |
Number of represented exact squared-distance levels, including zero. |
|
|
Topology/support |
Zero-based row centroid weighted by exact Euclidean distance. All-zero fields use the ordinary support centroid. |
|
|
Topology/support |
Zero-based column centroid weighted by exact Euclidean distance. All-zero fields use the ordinary support centroid. |
|
|
Topology/support |
Unnormalized exact distance-weighted central column moment. |
|
|
Topology/support |
Unnormalized exact distance-weighted central row moment. |
|
|
Topology/support |
Unnormalized exact distance-weighted mixed row-column moment. |
|
|
Topology/support |
Principal axis of the exact distance-weighted second moments, in degrees; isotropic fields return zero. |
|
|
Topology/support |
Major/minor eigenvalue ratio of the exact distance-weighted second moments, capped at |
Filled-Shape Attributes¶
These descriptors measure the region enclosed by the unique external boundary,
including its holes. Each node must have exactly one external boundary.
HOLE_AREA_FRACTION and FILLED_CENTROID_DISPLACEMENT_NORMALIZED compare that
filled region with the original support.
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Number of pixels enclosed by the unique external boundary, including holes; requires exactly one external boundary per live node. |
|
|
Topology/support |
Zero-based mean row of the filled region pixels. |
|
|
Topology/support |
Zero-based mean column of the filled region pixels. |
|
|
Topology/support |
Major-axis length proxy of the filled region, in pixels; follows |
|
|
Topology/support |
Minor-axis length proxy of the filled region, in pixels; follows |
|
|
Topology/support |
Non-negative principal column-axis orientation in degrees; isotropic regions return |
|
|
Topology/support |
Major/minor eigenvalue ratio of the filled region moments, capped at |
|
|
Topology/support |
Sum of the filled region second central moments divided by squared filled area. |
|
|
Topology/support |
Fraction of filled area occupied by holes: |
|
|
Topology/support |
Euclidean distance between support and filled-region centroids divided by the square root of filled area. |
|
|
Topology/support |
|
|
|
Topology/support |
Minor/major eigenvalue ratio of the filled-region second moments; one pixel returns |
Moment Attributes¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Second-order central moment |
|
|
Topology/support |
Second-order central moment |
|
|
Topology/support |
Mixed second-order central moment |
|
|
Topology/support |
Third-order central moment |
|
|
Topology/support |
Third-order central moment |
|
|
Topology/support |
Mixed third-order central moment |
|
|
Topology/support |
Mixed third-order central moment |
|
|
Topology/support |
First Hu moment invariant computed from normalized central moments. |
|
|
Topology/support |
Second Hu moment invariant. |
|
|
Topology/support |
Third Hu moment invariant. |
|
|
Topology/support |
Fourth Hu moment invariant. |
|
|
Topology/support |
Fifth Hu moment invariant. |
|
|
Topology/support |
Sixth Hu moment invariant. |
|
|
Topology/support |
Seventh Hu moment invariant. |
|
|
Topology/support |
Sum of normalized second-order central moments, |
|
|
Topology/support |
Area normalized by second-order dispersion, |
|
|
Topology/support |
Ratio of the largest to smallest eigenvalue of the second-moment matrix. |
|
|
Topology/support |
Length proxy for the major axis of the equivalent second-moment ellipse, derived from the largest inertia eigenvalue and area. |
|
|
Topology/support |
Length proxy for the minor axis of the equivalent second-moment ellipse, derived from the smallest inertia eigenvalue and area. |
|
|
Topology/support |
Principal-axis orientation in degrees, |
|
|
Topology/support |
Ratio |
Moment descriptors are useful when area alone is too coarse and the filter should react to shape geometry.
Boundary and Bitquad Attributes¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Topology/support |
Duda-style sub-pixel area estimator derived from aggregated |
|
|
Topology/support |
Euler-characteristic estimate from bitquad counts under the tree connectivity. |
|
|
Topology/support |
Number of holes inferred from the bitquad Euler characteristic for a single connected support. |
|
|
Topology/support |
Discrete boundary-length estimate from bitquad edge-contributing patterns. |
|
|
Topology/support |
Smoothed continuous perimeter estimate from bitquad counters, using weighted transitions across local |
|
|
Topology/support |
Bitquad compactness measure |
|
|
Topology/support |
Average continuous perimeter per connected component, computed from bitquad perimeter and Euler-count estimates. |
|
|
Topology/support |
Average longitudinal extent proxy, derived as half of the average continuous perimeter. |
|
|
Topology/support |
Average transverse extent proxy, computed as |
|
|
Topology/support |
Number of support pixels that touch the 4-neighbor complement by at least one side. |
|
|
Topology/support |
Total number of exposed 4-neighbor sides over the support. |
|
|
Topology/support |
Number of exposed north-facing sides over support pixels. |
|
|
Topology/support |
Number of exposed west-facing sides over support pixels. |
|
|
Topology/support |
Number of exposed east-facing sides over support pixels. |
|
|
Topology/support |
Number of exposed south-facing sides over support pixels. |
Boundary attributes are useful when perimeter, holes, or contour exposure are more informative than raw area.
Tree-Topology Attributes¶
Attribute |
Groups |
Contract |
Use |
|---|---|---|---|
|
|
Tree topology |
Longest child-edge path from the node to any leaf in its subtree. |
|
|
Tree topology |
Number of parent-edge steps from the node to the root. |
|
|
Tree topology |
Boolean scalar encoded as |
|
|
Tree topology |
Boolean scalar encoded as |
|
|
Tree topology |
Number of direct child nodes. |
|
|
Tree topology |
Number of other nodes sharing the same parent. |
|
|
Tree topology |
Number of internal tree nodes strictly below this node in its subtree. |
|
|
Tree topology |
Number of leaf nodes in the node subtree. |
|
|
Tree topology |
Ratio of leaf descendants to subtree size, |
|
|
Tree topology |
Difference between maximum and minimum child-subtree heights. |
|
|
Tree topology |
Average height of direct child subtrees. |
Tree-topology attributes ignore image coordinates and gray levels. They are useful when the hierarchy shape itself carries the signal.
Choosing Attributes¶
Start small:
use
AREAfor size filtering;add
GRAY_LEVEL_HEIGHTorVOLUMEwhen contrast matters;add
COMPACTNESS,ECCENTRICITY, orRATIO_WHwhen component shape matters;add
TREE_TOPOLOGYattributes when hierarchy position matters;use
BOUNDARYattributes for contour- or hole-sensitive filters;use
DIST_TRANSForDIST_TRANSF_EXACTfor interior-distance descriptors;use
FILLED_SHAPEto describe enclosed geometry and the effect of holes.
For CFP layers, each scalar attribute becomes an input feature for the scoring model after group expansion.
filter_spec = {
"name": "area_contrast_shape",
"tree_type": "max-tree",
"attributes": [
morphology.AttributeType.AREA,
morphology.AttributeType.GRAY_LEVEL_HEIGHT,
morphology.AttributeType.COMPACTNESS,
],
}