|
MorphologicalAttributeFilters
Public API documentation
|
Mutable morphological tree built directly on proper parts and dense node ids. More...
#include <MorphologicalTree.hpp>
Classes | |
| class | AliveNodeIterator |
| Iterator over live node ids in the dense internal-node domain. More... | |
| class | AliveNodeRange |
| Range wrapper for iterating over live node ids. More... | |
| class | BreadthFirstNodeIterator |
| Breadth-first iterator over one subtree. More... | |
| class | BreadthFirstNodeRange |
| Range wrapper for breadth-first subtree traversal. More... | |
| class | ChildrenIterator |
| Iterator over the direct children of one node. More... | |
| class | ChildrenRange |
| Range wrapper for direct-child iteration. More... | |
| class | ConnectedComponentIterator |
| Iterator over all proper parts in one connected component. More... | |
| class | ConnectedComponentRange |
| Range wrapper for connected-component proper-part iteration. More... | |
| class | DescendantNodeRange |
| Range wrapper over the proper descendants of one node. More... | |
| class | PathBetweenNodesIterator |
| Iterator over a materialised path between two nodes. More... | |
| class | PathBetweenNodesRange |
| Range wrapper for the path connecting two nodes in the same component. More... | |
| class | PathToRootIterator |
| Iterator that walks from a node towards the root. More... | |
| class | PathToRootRange |
| Range wrapper for rootward path traversal. More... | |
| class | PostOrderNodeIterator |
| Post-order iterator over one subtree. More... | |
| class | PostOrderNodeRange |
| Range wrapper for post-order subtree traversal. More... | |
| class | ProperPartsIterator |
| Iterator over the direct proper parts owned by one node. More... | |
| class | ProperPartsRange |
| Range wrapper for direct proper-part iteration. More... | |
| class | SubtreeNodeIterator |
| Depth-first iterator over a subtree in pre-order. More... | |
| class | SubtreeNodeRange |
| Range wrapper for pre-order subtree traversal. More... | |
Public Member Functions | |
| MorphologicalTree (const MorphologicalTree &)=delete | |
| Copying is disabled to keep topology ownership explicit. | |
| MorphologicalTree & | operator= (const MorphologicalTree &)=delete |
| Copy assignment is disabled to keep topology ownership explicit. | |
| MorphologicalTree (MorphologicalTree &&) noexcept=default | |
| Moving transfers the complete topology state. | |
| MorphologicalTree & | operator= (MorphologicalTree &&) noexcept=default |
| Move assignment transfers the complete topology state. | |
| virtual | ~MorphologicalTree ()=default |
| Destroys the topology storage and cached traversal state. | |
| template<AltitudeValue PixelType> | |
| MorphologicalTree (detail::MorphologicalTreeConstructionTag, ImagePtr< PixelType > imgPtr, ComponentTreeKind kind, double radius) | |
| Tag-protected constructor for image-based max/min component trees. | |
| MorphologicalTree (detail::MorphologicalTreeConstructionTag, ImageUInt8Ptr imgPtr, ToSInterpolation interpolation, int infinitySeedRow, int infinitySeedCol) | |
| Tag-protected constructor for image-based tree-of-shapes topology. | |
| MorphologicalTree (detail::MorphologicalTreeConstructionTag, std::span< const NodeId > parent, int rows, int cols, MorphologicalTreeKind kind, std::optional< AdjacencyRelation > adjacency) | |
| Tag-protected import from compact Higra parent representation. | |
| MorphologicalTree (detail::MorphologicalTreeConstructionTag, std::span< const NodeId > nodeParent, std::span< const NodeId > properPartOwner, NodeId root, int rows, int cols) | |
| Tag-protected import from native MAF topology buffers. | |
| MorphologicalTree | clone () const |
| Creates an independent copy of the structural tree state. | |
| std::size_t | getMutationVersion () const noexcept |
| Returns the monotonic mutation counter used by read-only views. | |
| void | requireMutationVersion (std::size_t expectedVersion, const char *context) const |
| Rejects stale read-only views that captured an older mutation version. | |
| int | getNumInternalNodeSlots () const |
| Returns the size of the dense internal-node id domain. | |
| int | getNumTotalProperParts () const |
| Returns the size of the proper-part domain. | |
| int | getNumHigraNodes () const |
| Returns the size of the preserved imported Higra node-id domain. | |
| int | getNodeIdSpaceSize (NodeIdSpace outputSpace) const |
| Returns the size of the requested node-id domain. | |
| NodeId | getHigraNodeId (NodeId nodeId) const noexcept |
| Returns the preserved imported Higra node id for one live tree node. | |
| NodeId | getRoot () const |
| Returns the current hierarchy root. | |
| bool | isNode (NodeId nodeId) const noexcept |
Tests whether nodeId belongs to the internal-node id domain. | |
| bool | isProperPart (NodeId id) const noexcept |
Tests whether id belongs to the proper-part domain. | |
| bool | isAlive (NodeId nodeId) const |
| Tests whether a node slot currently represents a live node. | |
| bool | isRoot (NodeId nodeId) const |
Tests whether nodeId is the current root. | |
| int | getNumFreeNodeSlots () const |
| Returns the number of currently reusable node slots. | |
| int | getNumLeafNodes () const |
| Counts the live nodes that currently have no children. | |
| int | getNumChildren (NodeId nodeId) const |
Returns the number of direct children of nodeId. | |
| int | getNodeNumDescendants (NodeId nodeId) const |
Returns the number of internal descendants of nodeId. | |
| int | getNodeNumSiblings (NodeId nodeId) const |
Returns the number of siblings of nodeId. | |
| int | getNodeTimePreOrder (NodeId nodeId) const |
Returns the preorder time of nodeId in the cached DFS traversal. | |
| int | getNodeTimePostOrder (NodeId nodeId) const |
Returns the postorder time of nodeId in the cached DFS traversal. | |
| NodeId | getFirstChild (NodeId nodeId) const |
Returns the first direct child of nodeId, or InvalidNode. | |
| NodeId | getNextSibling (NodeId nodeId) const |
Returns the next sibling of nodeId, or InvalidNode. | |
| bool | isLeaf (NodeId nodeId) const |
Tests whether nodeId has no direct children. | |
| int | getNumProperParts (NodeId nodeId) const |
Returns the number of direct proper parts owned by nodeId. | |
| bool | hasChild (NodeId parentNodeId, NodeId childId) const |
Tests whether childId is a direct child of parentNodeId. | |
| NodeId | getNodeParent (NodeId nodeId) const |
Returns the direct parent of nodeId. | |
| NodeId | getProperPartOwner (NodeId properPartId) const |
Returns the live node that directly owns properPartId. | |
| std::vector< NodeId > | getLeaves () const |
| Returns all live leaf nodes in the current hierarchy. | |
| MorphologicalTreeKind | getTreeType () const noexcept |
| Returns the current tree type. | |
| int | getNumNodes () const noexcept |
| Returns the number of currently live nodes. | |
| bool | isEditing () const noexcept |
| Tests whether a staged edit session is currently open. | |
| void | requireNotEditing (const char *context) const |
| Rejects operations that require a committed connected topology. | |
| bool | hasDetachedAliveNodes () const noexcept |
| Returns whether the tree currently contains alive detached nodes. | |
| bool | hasAdjacencyRelation () const noexcept |
| Tests whether an adjacency relation is attached to the tree. | |
| bool | hasTreeOfShapesAdjacencyPolicy () const noexcept |
| Tests whether this image-built tree of shapes carries min/max auxiliary adjacency metadata. | |
| double | getTreeOfShapesMinTreeAdjacencyRadius () const |
| Returns the auxiliary min-tree adjacency radius used by the ToS interpolation policy. | |
| double | getTreeOfShapesMaxTreeAdjacencyRadius () const |
| Returns the auxiliary max-tree adjacency radius used by the ToS interpolation policy. | |
| const AdjacencyRelation * | getTreeOfShapesMinTreeAdjacencyRelation () const noexcept |
| Returns the auxiliary min-tree adjacency relation used by the ToS interpolation policy. | |
| const AdjacencyRelation * | getTreeOfShapesMaxTreeAdjacencyRelation () const noexcept |
| Returns the auxiliary max-tree adjacency relation used by the ToS interpolation policy. | |
| int | getNumRowsOfImage () const |
| Returns the number of image rows in the attached 2D domain. | |
| int | getNumColsOfImage () const |
| Returns the number of image columns in the attached 2D domain. | |
| AdjacencyRelation * | getAdjacencyRelation () noexcept |
| Returns the mutable adjacency relation attached to the tree, if any. | |
| const AdjacencyRelation * | getAdjacencyRelation () const noexcept |
| Returns the read-only adjacency relation attached to the tree, if any. | |
| void | validateConnectedRootedTree () const |
| Validates that the current structure is one connected rooted tree. | |
| TreeValidationResult | validateConnectedRootedTreeResult () const noexcept |
| Runs strong validation and returns the result instead of throwing. | |
| bool | isAncestor (NodeId u, NodeId v) const |
Tests whether u is an ancestor of v. | |
| bool | isDescendant (NodeId u, NodeId v) const |
Tests whether u is a descendant of v. | |
| bool | isComparable (NodeId u, NodeId v) const |
Tests whether u and v are comparable in the ancestry order. | |
| bool | isStrictAncestor (NodeId u, NodeId v) const |
Tests whether u is a strict ancestor of v. | |
| bool | isStrictDescendant (NodeId u, NodeId v) const |
Tests whether u is a strict descendant of v. | |
| bool | isStrictComparable (NodeId u, NodeId v) const |
Tests whether u and v are strictly comparable in the ancestry order. | |
| NodeId | getLowestCommonAncestor (NodeId u, NodeId v) const |
Returns the lowest common ancestor of u and v. | |
| AliveNodeRange | getAliveNodeIds () const |
| Returns a fail-fast range over all live node ids. | |
| ChildrenRange | getChildren (NodeId nodeId) const |
Returns a fail-fast range over the direct children of nodeId. | |
| ProperPartsRange | getProperParts (NodeId nodeId) const |
Returns a fail-fast range over the direct proper parts of nodeId. | |
| ConnectedComponentRange | getConnectedComponent (NodeId nodeId) const |
Returns a fail-fast range over all proper parts in the connected component represented by nodeId. | |
| PostOrderNodeRange | getPostOrderNodes () const |
| Returns a post-order traversal range rooted at the connected root. | |
| PostOrderNodeRange | getPostOrderNodes (NodeId rootNodeId) const |
Returns a post-order traversal range rooted at rootNodeId. | |
| BreadthFirstNodeRange | getIteratorBreadthFirstTraversal () const |
| Returns a breadth-first traversal range rooted at the connected root. | |
| BreadthFirstNodeRange | getIteratorBreadthFirstTraversal (NodeId rootNodeId) const |
Returns a breadth-first traversal range rooted at rootNodeId. | |
| PathToRootRange | getPathToRootNodes (NodeId nodeId) const |
Returns the path from nodeId to the connected root. | |
| PathBetweenNodesRange | getPathBetweenNodes (NodeId sourceNodeId, NodeId targetNodeId) const |
Returns the path that connects sourceNodeId and targetNodeId. | |
| SubtreeNodeRange | getNodeSubtree (NodeId nodeId) const |
Returns a pre-order traversal range over the subtree of nodeId. | |
| DescendantNodeRange | getDescendants (NodeId nodeId) const |
Returns a range over all proper descendants of nodeId. | |
| TreeEditor | edit () |
| Opens the only public entrypoint for staged structural mutations. | |
| void | pruneNode (NodeId nodeId) |
Prunes the subtree of nodeId, moving all its support to the parent. | |
| void | mergeNodeIntoParent (NodeId nodeId) |
Merges nodeId into its parent and releases the emptied slot. | |
Friends | |
| class | TreeEditor |
Mutable morphological tree built directly on proper parts and dense node ids.
MorphologicalTree is the central mutable hierarchy of this project. It can represent a max-tree, min-tree, or tree of shapes and exposes a dense NodeId domain together with direct proper-part ownership. The class keeps explicit parent/child links, linked lists of direct proper parts, optional 2D image-domain metadata, and a small set of structural caches used by the public traversal and ancestry queries.
Data model:
NodeId in the range [0, getNumTotalProperParts());NodeId in the range [0, getNumInternalNodeSlots());Main responsibilities:
WeightedMorphologicalTree<std::uint8_t>.The class intentionally keeps only the canonical structural state and a small number of derived caches. Higher-level attribute computation is delegated to the incremental attribute computers in mmcfilters/attributes.
Definition at line 120 of file MorphologicalTree.hpp.
|
inline |
Tag-protected constructor for image-based max/min component trees.
The factory owns this path. The resulting topology uses the image pixels as proper parts, stores the selected component-tree type internally, and keeps the adjacency relation used by later topology-aware operations.
Definition at line 989 of file MorphologicalTree.hpp.
|
inline |
Tag-protected constructor for image-based tree-of-shapes topology.
The factory owns this path. The topology uses the image pixels as proper parts and stores the ToS interpolation policy as adjacency metadata for operations that need to preserve the same interpretation.
Definition at line 1034 of file MorphologicalTree.hpp.
|
inline |
Tag-protected import from compact Higra parent representation.
Higra ids are leaves first and internal nodes after the image-domain leaves. The constructor converts internal Higra ids to dense internal NodeId slots while preserving enough mapping metadata for weighted altitude import. Max/min imports require an adjacency relation; tree of shapes imports can omit it.
Definition at line 1080 of file MorphologicalTree.hpp.
|
inline |
Tag-protected import from native MAF topology buffers.
This path is used by builders that already materialize internal-node parent links and row-major proper-part owners, such as the SDRT builder. The buffers are copied into canonical tree storage and validated as one connected rooted hierarchy.
Definition at line 1167 of file MorphologicalTree.hpp.
|
inline |
Creates an independent copy of the structural tree state.
The public copy constructor stays deleted so ownership remains explicit at API boundaries. This method is used by wrappers that need to preserve a caller-owned topology while creating a new tree-backed object.
Definition at line 1255 of file MorphologicalTree.hpp.
|
inline |
Opens the only public entrypoint for staged structural mutations.
Use this for multi-step topology rewiring that may temporarily detach nodes, move children/proper parts, or create intermediate nodes. TreeEditor::commit() runs the strong connected-rooted-tree validation.
Defined in TreeEditor.hpp after TreeEditor is complete; at this point only the forward declaration is available.
Definition at line 337 of file TreeEditor.hpp.
|
inlinenoexcept |
Returns the read-only adjacency relation attached to the tree, if any.
Definition at line 1688 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the mutable adjacency relation attached to the tree, if any.
Definition at line 1683 of file MorphologicalTree.hpp.
|
inline |
Returns a fail-fast range over all live node ids.
Definition at line 1973 of file MorphologicalTree.hpp.
|
inline |
Returns a fail-fast range over the direct children of nodeId.
Definition at line 1980 of file MorphologicalTree.hpp.
|
inline |
Returns a fail-fast range over all proper parts in the connected component represented by nodeId.
The range walks the subtree rooted at nodeId and yields every direct proper part owned by those nodes, without materialising a vector.
Definition at line 2000 of file MorphologicalTree.hpp.
|
inline |
Returns a range over all proper descendants of nodeId.
Definition at line 2063 of file MorphologicalTree.hpp.
Returns the first direct child of nodeId, or InvalidNode.
Definition at line 1484 of file MorphologicalTree.hpp.
Returns the preserved imported Higra node id for one live tree node.
Returns InvalidNode when the original Higra node-id space is not preserved.
Definition at line 1374 of file MorphologicalTree.hpp.
|
inline |
Returns a breadth-first traversal range rooted at the connected root.
Definition at line 2023 of file MorphologicalTree.hpp.
|
inline |
Returns a breadth-first traversal range rooted at rootNodeId.
Definition at line 2030 of file MorphologicalTree.hpp.
|
inline |
Returns all live leaf nodes in the current hierarchy.
Definition at line 1551 of file MorphologicalTree.hpp.
Returns the lowest common ancestor of u and v.
Definition at line 1951 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the monotonic mutation counter used by read-only views.
Definition at line 1316 of file MorphologicalTree.hpp.
Returns the next sibling of nodeId, or InvalidNode.
Definition at line 1492 of file MorphologicalTree.hpp.
|
inline |
Returns the size of the requested node-id domain.
NodeIdSpace::HIGRA means the preserved imported Higra domain, not the compact domain that would be generated by exporting the current tree.
Definition at line 1358 of file MorphologicalTree.hpp.
Returns the number of internal descendants of nodeId.
Definition at line 1444 of file MorphologicalTree.hpp.
Returns the number of siblings of nodeId.
Definition at line 1454 of file MorphologicalTree.hpp.
Returns the direct parent of nodeId.
The root and detached nodes report themselves as parent.
Definition at line 1524 of file MorphologicalTree.hpp.
|
inline |
Returns a pre-order traversal range over the subtree of nodeId.
Definition at line 2055 of file MorphologicalTree.hpp.
Returns the postorder time of nodeId in the cached DFS traversal.
Definition at line 1475 of file MorphologicalTree.hpp.
Returns the preorder time of nodeId in the cached DFS traversal.
Definition at line 1466 of file MorphologicalTree.hpp.
Returns the number of direct children of nodeId.
Definition at line 1436 of file MorphologicalTree.hpp.
|
inline |
Returns the number of image columns in the attached 2D domain.
Definition at line 1676 of file MorphologicalTree.hpp.
|
inline |
Returns the number of currently reusable node slots.
Definition at line 1418 of file MorphologicalTree.hpp.
|
inline |
Returns the size of the preserved imported Higra node-id domain.
| std::runtime_error | if the tree was not imported from Higra or if the preserved Higra node-id space was invalidated by an edit. |
Definition at line 1345 of file MorphologicalTree.hpp.
|
inline |
Returns the size of the dense internal-node id domain.
Some slots may currently be free and therefore not correspond to live nodes.
Definition at line 1332 of file MorphologicalTree.hpp.
|
inline |
Counts the live nodes that currently have no children.
Definition at line 1423 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the number of currently live nodes.
Definition at line 1580 of file MorphologicalTree.hpp.
Returns the number of direct proper parts owned by nodeId.
Definition at line 1505 of file MorphologicalTree.hpp.
|
inline |
Returns the number of image rows in the attached 2D domain.
Definition at line 1669 of file MorphologicalTree.hpp.
|
inline |
Returns the size of the proper-part domain.
Definition at line 1337 of file MorphologicalTree.hpp.
|
inline |
Returns the path that connects sourceNodeId and targetNodeId.
Definition at line 2046 of file MorphologicalTree.hpp.
|
inline |
Returns the path from nodeId to the connected root.
Definition at line 2038 of file MorphologicalTree.hpp.
|
inline |
Returns a post-order traversal range rooted at the connected root.
Definition at line 2008 of file MorphologicalTree.hpp.
|
inline |
Returns a post-order traversal range rooted at rootNodeId.
Definition at line 2015 of file MorphologicalTree.hpp.
Returns the live node that directly owns properPartId.
Definition at line 1542 of file MorphologicalTree.hpp.
|
inline |
Returns a fail-fast range over the direct proper parts of nodeId.
Definition at line 1988 of file MorphologicalTree.hpp.
|
inline |
Returns the current hierarchy root.
Definition at line 1384 of file MorphologicalTree.hpp.
|
inline |
Returns the auxiliary max-tree adjacency radius used by the ToS interpolation policy.
Definition at line 1645 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the auxiliary max-tree adjacency relation used by the ToS interpolation policy.
Definition at line 1662 of file MorphologicalTree.hpp.
|
inline |
Returns the auxiliary min-tree adjacency radius used by the ToS interpolation policy.
Definition at line 1635 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the auxiliary min-tree adjacency relation used by the ToS interpolation policy.
Definition at line 1655 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns the current tree type.
Definition at line 1575 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Tests whether an adjacency relation is attached to the tree.
Definition at line 1625 of file MorphologicalTree.hpp.
Tests whether childId is a direct child of parentNodeId.
Definition at line 1513 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Returns whether the tree currently contains alive detached nodes.
Detached alive nodes are self-parented nodes other than the connected root. They are allowed during explicit edit sessions but make the hierarchy a forest rather than a single rooted tree.
Definition at line 1603 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Tests whether this image-built tree of shapes carries min/max auxiliary adjacency metadata.
Definition at line 1630 of file MorphologicalTree.hpp.
Tests whether a node slot currently represents a live node.
Definition at line 1399 of file MorphologicalTree.hpp.
Tests whether u is an ancestor of v.
Definition at line 1906 of file MorphologicalTree.hpp.
Tests whether u and v are comparable in the ancestry order.
Definition at line 1931 of file MorphologicalTree.hpp.
Tests whether u is a descendant of v.
Definition at line 1919 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Tests whether a staged edit session is currently open.
Definition at line 1585 of file MorphologicalTree.hpp.
Tests whether nodeId has no direct children.
Definition at line 1500 of file MorphologicalTree.hpp.
Tests whether nodeId belongs to the internal-node id domain.
Definition at line 1389 of file MorphologicalTree.hpp.
Tests whether id belongs to the proper-part domain.
Definition at line 1394 of file MorphologicalTree.hpp.
Tests whether nodeId is the current root.
Definition at line 1413 of file MorphologicalTree.hpp.
Tests whether u is a strict ancestor of v.
Definition at line 1936 of file MorphologicalTree.hpp.
Tests whether u and v are strictly comparable in the ancestry order.
Definition at line 1946 of file MorphologicalTree.hpp.
Tests whether u is a strict descendant of v.
Definition at line 1941 of file MorphologicalTree.hpp.
Merges nodeId into its parent and releases the emptied slot.
This is a safe committed edit: children and direct proper parts are transferred to the parent before the node slot is released. The operation advances the tree mutation version and invalidates derived state.
Definition at line 2128 of file MorphologicalTree.hpp.
Prunes the subtree of nodeId, moving all its support to the parent.
This is a safe committed edit: it is a complete local operation and does not intentionally leave the tree in a staged disconnected state, but it still advances the tree mutation version and invalidates derived state.
Definition at line 2087 of file MorphologicalTree.hpp.
|
inline |
Rejects stale read-only views that captured an older mutation version.
Definition at line 1321 of file MorphologicalTree.hpp.
Rejects operations that require a committed connected topology.
Definition at line 1590 of file MorphologicalTree.hpp.
|
inline |
Validates that the current structure is one connected rooted tree.
This validation is intended for edit-session commits and debug/invariant checks. It is intentionally stronger than the local runtime guards used by low-level mutators.
Definition at line 1697 of file MorphologicalTree.hpp.
|
inlinenoexcept |
Runs strong validation and returns the result instead of throwing.
Definition at line 1892 of file MorphologicalTree.hpp.
|
friend |
Definition at line 122 of file MorphologicalTree.hpp.