mmcfilters
Public API documentation
Loading...
Searching...
No Matches
mmcfilters::MorphologicalTreeFactory Class Reference

Public construction facade for all high-level morphological trees. More...

#include <MorphologicalTreeFactory.hpp>

Static Public Member Functions

template<AltitudeValue T>
static ValuedMorphologicalTree< T > createMaxTree (ImagePtr< T > img, double radius=1.5)
 Builds a typed valuedTree max-tree from an image.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createMaxTree (ImagePtr< T > img, RegularGridAdjacency2D adjacency)
 Builds a max-tree with an explicit regular-grid 2D adjacency.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createMinTree (ImagePtr< T > img, double radius=1.5)
 Builds a typed valuedTree min-tree from an image.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createMinTree (ImagePtr< T > img, RegularGridAdjacency2D adjacency)
 Builds a min-tree with an explicit regular-grid 2D adjacency.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createExtremumResidualTree (ImagePtr< T > img, RegularGridAdjacency2D adjacency)
 Builds the extremum residual tree through synchronized component trees.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createExtremumResidualTree (ImagePtr< T > img, double radius=1.5)
 Builds the extremum residual tree through synchronized component trees with a radius adjacency.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createExtremumResidualTreeByCTs (ImagePtr< T > img, RegularGridAdjacency2D adjacency)
 Builds the extremum residual tree by synchronized component trees.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createExtremumResidualTreeByCTs (ImagePtr< T > img, double radius=1.5)
 Builds the extremum residual tree with a radius adjacency.
template<class Altitude = std::uint8_t>
static ValuedMorphologicalTree< Altitude > createTreeOfShapes (ImageUInt8Ptr img, TopographicConvention convention={})
 Builds a valued tree of shapes from an 8-bit image.
template<AltitudeValue T>
static ValuedMorphologicalTree< T > createFromHigraParent (std::span< const NodeId > parent, std::span< const T > nodeAltitudes, int rows, int columns, MorphologicalTreeKind kind, std::optional< RegularGridAdjacency2D > adjacency=std::nullopt)
 Imports a static Higra parent/altitude hierarchy.

Detailed Description

Public construction facade for all high-level morphological trees.

MorphologicalTreeFactory is the single public entry point for creating tree instances from images and static Higra hierarchies. The factory owns only construction orchestration; it does not store mutable build state and every construction method returns a fully initialized valued-tree owner.

Design contract:

  • builders whose nodes may have an empty proper part supply explicit node altitudes together with their native topology;
  • Higra imports preserve the external Higra node-id domain for altitude mapping, then expose the result through the internal dense NodeId domain;
  • callers that only need topology should use ValuedMorphologicalTree<std::uint8_t>::topology() instead of constructing a bare MorphologicalTree directly;
  • max/min image factories derive altitude type from the image type. uint8_t uses counting sort; other supported altitude values use comparison sort;
  • static Higra imports can preserve a non-canonical altitude type because the altitude array itself supplies that type.

Keeping construction in this factory prevents MorphologicalTree and ValuedMorphologicalTree<std::uint8_t> from depending on public factory logic while still allowing their tag-based constructors to remain available for header-only composition inside this library.

Definition at line 50 of file MorphologicalTreeFactory.hpp.

Member Function Documentation

◆ createExtremumResidualTree() [1/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createExtremumResidualTree ( ImagePtr< T > img,
double radius = 1.5 )
inlinestaticnodiscard

Builds the extremum residual tree through synchronized component trees with a radius adjacency.

Parameters
imgNonempty image with finite altitude values.
radiusRadius of the regular-grid adjacency.
Returns
Valued extremum residual tree owning the completed topology and altitudes.

Definition at line 176 of file MorphologicalTreeFactory.hpp.

◆ createExtremumResidualTree() [2/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createExtremumResidualTree ( ImagePtr< T > img,
RegularGridAdjacency2D adjacency )
inlinestaticnodiscard

Builds the extremum residual tree through synchronized component trees.

Parameters
imgNonempty image with finite altitude values.
adjacencyConnected adjacency matching the image domain.
Returns
Valued extremum residual tree owning the completed topology and altitudes.

Definition at line 164 of file MorphologicalTreeFactory.hpp.

◆ createExtremumResidualTreeByCTs() [1/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createExtremumResidualTreeByCTs ( ImagePtr< T > img,
double radius = 1.5 )
inlinestaticnodiscard

Builds the extremum residual tree with a radius adjacency.

Parameters
imgNon-null, nonempty image with finite altitude values.
radiusRadius inducing a connected adjacency on the image domain.
Returns
An extremum residual tree using the radius adjacency.

Definition at line 207 of file MorphologicalTreeFactory.hpp.

◆ createExtremumResidualTreeByCTs() [2/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createExtremumResidualTreeByCTs ( ImagePtr< T > img,
RegularGridAdjacency2D adjacency )
inlinestaticnodiscard

Builds the extremum residual tree by synchronized component trees.

Current regional extrema from the synchronized max-tree and min-tree are selected by the self-dual residual schedule. Both component trees use the same symmetric connected adjacency.

Parameters
imgNon-null, nonempty image with finite altitude values.
adjacencyConnected adjacency matching the image domain.
Returns
An extremum residual tree over adjacency.

Definition at line 193 of file MorphologicalTreeFactory.hpp.

◆ createFromHigraParent()

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createFromHigraParent ( std::span< const NodeId > parent,
std::span< const T > nodeAltitudes,
int rows,
int columns,
MorphologicalTreeKind kind,
std::optional< RegularGridAdjacency2D > adjacency = std::nullopt )
inlinestaticnodiscard

Imports a static Higra parent/altitude hierarchy.

Higra arrays use one compact id domain containing leaves followed by internal nodes. For an image domain with rows * columns leaves, leaf ids are [0, rows * columns) and internal ids are [rows * columns, parent.size()). Every leaf must point to an internal node, every internal node must point to another internal node or to itself, and exactly one internal node must be self-parented as the root.

Parameters
parentParent array in the compact Higra id domain.
nodeAltitudesAltitudes in the same compact Higra id domain.
rowsNumber of rows in the image/pixel domain.
columnsNumber of columns in the image/pixel domain.
kindSemantic tree kind represented by the imported hierarchy.
adjacencyRequired for max-tree and min-tree imports. Optional for tree-of-shapes imports, whose topology can be interpreted without a component-tree adjacency relation.
Returns
A typed valued tree whose internal altitude buffer has already been remapped from Higra ids to internal NodeId slots.
Exceptions
std::invalid_argumentif the hierarchy is malformed, if the altitude domain does not match the parent domain, or if a max/min import does not provide adjacency.

Definition at line 268 of file MorphologicalTreeFactory.hpp.

◆ createMaxTree() [1/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createMaxTree ( ImagePtr< T > img,
double radius = 1.5 )
inlinestaticnodiscard

Builds a typed valuedTree max-tree from an image.

Parameters
imgNon-null, non-empty image. Its row/column domain becomes the pixel domain of the resulting tree, and its pixel type becomes the altitude type of the returned owner.
radiusRadius used by the component-tree adjacency relation.
Returns
A ValuedMorphologicalTree<T> whose topology is a max-tree and whose altitude buffer is indexed by internal NodeId.
Exceptions
std::invalid_argumentif the image domain is invalid.

Definition at line 92 of file MorphologicalTreeFactory.hpp.

◆ createMaxTree() [2/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createMaxTree ( ImagePtr< T > img,
RegularGridAdjacency2D adjacency )
inlinestaticnodiscard

Builds a max-tree with an explicit regular-grid 2D adjacency.

The relation may be radius-, rectangle-, line-, or structuring-element-based. Its grid dimensions must match img.

Parameters
imgImage.
adjacencyAdjacency relation.
Returns
The resulting max-tree with an explicit regular-grid 2D adjacency.

Definition at line 110 of file MorphologicalTreeFactory.hpp.

◆ createMinTree() [1/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createMinTree ( ImagePtr< T > img,
double radius = 1.5 )
inlinestaticnodiscard

Builds a typed valuedTree min-tree from an image.

Parameters
imgNon-null, non-empty image. Its row/column domain becomes the pixel domain of the resulting tree, and its pixel type becomes the altitude type of the returned owner.
radiusRadius used by the component-tree adjacency relation.
Returns
A ValuedMorphologicalTree<T> whose topology is a min-tree and whose altitude buffer is indexed by internal NodeId.
Exceptions
std::invalid_argumentif the image domain is invalid.

Definition at line 132 of file MorphologicalTreeFactory.hpp.

◆ createMinTree() [2/2]

template<AltitudeValue T>
ValuedMorphologicalTree< T > mmcfilters::MorphologicalTreeFactory::createMinTree ( ImagePtr< T > img,
RegularGridAdjacency2D adjacency )
inlinestaticnodiscard

Builds a min-tree with an explicit regular-grid 2D adjacency.

Parameters
imgImage.
adjacencyAdjacency relation.
Returns
The resulting min-tree with an explicit regular-grid 2D adjacency.

Definition at line 147 of file MorphologicalTreeFactory.hpp.

◆ createTreeOfShapes()

template<class Altitude = std::uint8_t>
ValuedMorphologicalTree< Altitude > mmcfilters::MorphologicalTreeFactory::createTreeOfShapes ( ImageUInt8Ptr img,
TopographicConvention convention = {} )
inlinestaticnodiscard

Builds a valued tree of shapes from an 8-bit image.

The published altitude type must match the altitude encoding declared by the convention. The default convention selects the canonical minimum-4/maximum-8 complementary-grid immersion without domain padding, uses infinity pixel zero, and publishes unchanged 8-bit source levels. ToSGrayLevel altitudes are available under TopographicAltitudeEncoding::ExactDoubled. A self-dual span immersion requires that encoding when it retains an exterior ring; without the ring, TopographicAltitudeEncoding::UInt8 is also exact and admissible.

Template Parameters
AltitudePublished node-altitude type.
Parameters
imgNon-null, non-empty image.
conventionComplete topographic convention retained by the result.
Returns
A ValuedMorphologicalTree<Altitude> whose topology is a tree of shapes and whose altitude buffer is indexed by internal NodeId.
Exceptions
std::invalid_argumentif the image domain or ToS parameters are rejected by the underlying builder, or if Altitude contradicts the declared altitude encoding.

Definition at line 235 of file MorphologicalTreeFactory.hpp.


The documentation for this class was generated from the following file: