8#include "../utils/Common.hpp"
9#include "../utils/RegularGridAdjacency2D.hpp"
73using TreeOfShapesImmersion = std::variant<CanonicalComplementaryGridImmersion, ComplementaryGridImmersion, SelfDualSpanImmersion>;
119 std::variant<NoConstructionContext, SharedAdjacencyContext, TopographicConvention>;
136 case MorphologicalTreeKind::MaxTree:
137 return NodeAltitudeOrder::Increasing;
138 case MorphologicalTreeKind::MinTree:
139 return NodeAltitudeOrder::Decreasing;
140 case MorphologicalTreeKind::Generic:
141 case MorphologicalTreeKind::TreeOfShapes:
142 case MorphologicalTreeKind::ExtremumResidualTree:
143 return NodeAltitudeOrder::Unconstrained;
145 return NodeAltitudeOrder::Unconstrained;
152 return MorphologicalTreeSemantics{kind, defaultNodeAltitudeOrder(kind), std::move(constructionContext)};
165 throw std::invalid_argument(
"Morphological-tree kind and node-altitude order are incompatible.");
171 if (semantics.
kind == MorphologicalTreeKind::Generic || semantics.
kind == MorphologicalTreeKind::MaxTree ||
172 semantics.
kind == MorphologicalTreeKind::MinTree || semantics.
kind == MorphologicalTreeKind::ExtremumResidualTree) {
175 throw std::invalid_argument(
"SharedAdjacencyContext is incompatible with the declared morphological-tree kind.");
178 if (semantics.
kind == MorphologicalTreeKind::TreeOfShapes) {
181 throw std::invalid_argument(
"TopographicConvention requires TreeOfShapes kind.");
183 throw std::invalid_argument(
"Unsupported morphological-tree construction context.");
MorphologicalTreeSemantics makeMorphologicalTreeSemantics(MorphologicalTreeKind kind, MorphologicalTreeConstructionContext constructionContext=NoConstructionContext{})
Constructs semantics using the conventional altitude order of kind.
TopographicConvention selfDualSpanConvention(TopographicDomainExtension domainExtension=TopographicDomainExtension::ExteriorRing, PixelId infinityPixel=0, TopographicAltitudeEncoding altitudeEncoding=TopographicAltitudeEncoding::ExactDoubled)
Builds a self-dual span convention in one call.
std::variant< NoConstructionContext, SharedAdjacencyContext, TopographicConvention > MorphologicalTreeConstructionContext
Tagged construction context retained by morphological-tree semantics.
NodeAltitudeOrder
Global ordering constraint of node altitudes along parent-child arcs.
@ Unconstrained
No global parent-child altitude order is declared.
@ Decreasing
Every alive parent-child arc satisfies nodeAltitude(parent) > nodeAltitude(child).
@ Increasing
Every alive parent-child arc satisfies nodeAltitude(parent) < nodeAltitude(child).
TopographicDomainExtension
Relation between the source pixel domain and active topographic domain.
std::variant< CanonicalComplementaryGridImmersion, ComplementaryGridImmersion, SelfDualSpanImmersion > TreeOfShapesImmersion
Tagged tree-of-shapes immersion family.
TopographicAltitudeEncoding
Scale in which tree-of-shapes node altitudes are published.
MorphologicalTreeKind
Declared construction family of one morphological tree.
NodeAltitudeOrder defaultNodeAltitudeOrder(MorphologicalTreeKind kind) noexcept
Returns the conventional node-altitude order of a declared tree kind.
void validateMorphologicalTreeSemantics(const MorphologicalTreeSemantics &semantics)
Validates the scientific compatibility of a semantics descriptor.
ComplementaryPairing
Canonical ordered pairing of complementary 4- and 8-connectivities.
Immutable regular-grid 2D adjacency with allocation-free traversal.
Selects a canonical complementary-grid immersion without binding a domain.
ComplementaryPairing pairing
Canonical minimum/maximum pairing.
Ordered pair of complementary minimum and maximum adjacencies.
RegularGridAdjacency2D minAdjacency
Adjacency used for minimum-oriented processing.
RegularGridAdjacency2D maxAdjacency
Adjacency used for maximum-oriented processing.
Selects the optimized complementary-grid immersion.
ComplementaryAdjacencies complementaryAdjacencies
Ordered minimum/maximum adjacency pair.
Owning result for one computed scalar attribute layout and buffer.
Immutable scientific interpretation attached to one morphological tree.
NodeAltitudeOrder nodeAltitudeOrder
Global parent-child altitude order.
MorphologicalTreeConstructionContext constructionContext
Typed retained construction context.
MorphologicalTreeKind kind
Declared construction/result kind.
Explicitly records that no construction context is available.
Selects the self-dual span-valued tree-of-shapes immersion.
Records one adjacency shared by both construction polarities.
RegularGridAdjacency2D adjacency
Shared construction adjacency.
Complete discrete convention retained by a tree-of-shapes result.
TreeOfShapesImmersion immersion
Selected topographic immersion.
TopographicAltitudeEncoding altitudeEncoding
Published node-altitude scale.
PixelId infinityPixel
Declared infinity pixel in the active topographic domain.
TopographicDomainExtension domainExtension
Active-domain extension convention.