|
MorphologicalAttributeFilters
Public API documentation
|
This guide describes the public tree model used by mmcfilters. It is the orientation document for MorphologicalTree, WeightedMorphologicalTree<T>, WeightedTreeView<T>, construction factories, node-id domains, edits, and Higra interoperability.
The public tree API separates three concerns:
MorphologicalTree owns topology only.WeightedMorphologicalTree<T> owns topology plus a dense altitude buffer.WeightedTreeView<T> borrows topology plus an external altitude span.MorphologicalTree stores:
NodeId slots;It does not own node altitudes. Any operation that reads or mutates altitude must use WeightedMorphologicalTree<T> or a read-only WeightedTreeView<T>.
The implemented high-level tree kinds are:
MAX_TREE: component tree whose altitude is non-decreasing from parent to child.MIN_TREE: component tree whose altitude is non-increasing from parent to child.TREE_OF_SHAPES: tree of shapes built from the 8-bit ToS construction path; monotone altitude validation is not applied globally.SELF_DUAL_RESIDUAL_TREE: self-dual residual tree built from paired min/max component-tree seeds.Component trees require an image-domain adjacency relation. On the 2D square grid, radius=1.0 corresponds to 4-connectivity and radius=1.5 corresponds to 8-connectivity.
Some attributes are tree-kind dependent. For example, MAX_DIST is currently defined for max-trees and min-trees with adjacency metadata and rejects tree-of-shapes and self-dual residual trees explicitly.
Use MorphologicalTreeFactory for public construction:
C++ max-tree and min-tree factories are typed:
Python construction is intentionally narrower:
np.uint8 arrays;WeightedMorphologicalTree binding;int32 or float32 tree owners.Use WeightedMorphologicalTree<T> when the operation needs ownership:
Use WeightedTreeView<T> for read-only C++ kernels that should not own or copy altitude storage:
The caller must keep the topology and altitude storage alive for the lifetime of the view. The view captures the topology mutation version and rejects reads when the topology changes.
The canonical tree domain is the dense internal NodeId space:
Some internal slots may be dead after edits. Node-indexed buffers keep the full slot count so existing row ids remain addressable. Iterate tree.getAliveNodeIds() when consuming live tree nodes.
Image pixels are proper parts. They use row-major linear ids:
The key ownership queries are:
getProperParts(node) returns only the direct proper parts owned by node. getConnectedComponent(node) returns the full subtree support.
Altitude buffers are indexed by dense internal NodeId:
WeightedMorphologicalTree<T> owns an AltitudeBuffer<T>. WeightedTreeView<T> borrows an AltitudeSpan<T>. Accepted altitude types satisfy AltitudeValue:
bool is rejected.Max-trees and min-trees validate monotone altitude order. Trees of shapes and self-dual residual trees currently skip global monotone-altitude validation because their semantics are not a single max/min component-tree order. Operators that need classical altitude polarity, such as MSER, therefore reject those tree kinds; use topological depth-stability operators when delta should mean a number of tree edges instead of an altitude difference. ExtinctionValues is also restricted to max-trees and min-trees because it currently identifies regional extrema with component-tree leaves.
Safe committed edits are public:
Multi-step topology changes must go through an editor session:
Weighted edits use WeightedMorphologicalTree<T>::edit() and additionally validate altitude order on commit.
Topology mutations advance the tree mutation version. Objects that cache node-indexed state against a tree reject reads after the topology changes. This includes:
ContoursComputedIncrementally::IncrementalContours;AttributeFilters;ExtinctionValues;UltimateAttributeOpening.Plain attribute result buffers are not versioned; recompute them after topology mutation.
createFromHigraParent(...) imports a compact Higra-style hierarchy whose external layout is:
The imported Higra node-id domain is preserved only until topology mutation. NodeIdSpace::HIGRA refers to that preserved imported domain, while exportHigraHierarchy() creates a fresh compact snapshot for the current live tree. For import/export rules and attribute projection to both domains, see Higra Interoperability.
Python exposes the stable owner-oriented surface:
Python does not expose TreeEditor, WeightedTreeEditor, unchecked altitude setters, or a mutable topology handle from WeightedMorphologicalTree.
NodeId domains, attributes, filters, contours, and Higra interop.