MorphologicalAttributeFilters
Public API documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
mmcfilters::AdjacencyRelation Class Reference

Two-dimensional adjacency relation with configurable radius and efficient iteration. More...

#include <AdjacencyRelation.hpp>

Classes

class  IteratorAdjacency
 Lightweight iterator over the currently configured traversal. More...
 

Public Member Functions

 AdjacencyRelation (int numRows, int numCols, double radius)
 Builds an adjacency relation for a numRows by numCols image.
 
int nextValid ()
 Advances to the next valid offset under the current bounds and mode.
 
int getSize () const
 Returns the number of offsets in the current stencil.
 
int getNumRows () const noexcept
 Returns the number of rows in the attached image domain.
 
int getNumCols () const noexcept
 Returns the number of columns in the attached image domain.
 
AdjacencyRelationgetAdjPixels (int row, int col)
 Prepares iteration over adjacent pixels, including the origin.
 
AdjacencyRelationgetAdjPixels (int indexVector)
 Prepares iteration over adjacent pixels from a linear index, including the origin.
 
AdjacencyRelationgetNeighborPixels (int row, int col)
 Prepares iteration over valid neighbouring pixels, excluding the origin.
 
AdjacencyRelationgetNeighborPixels (int indexVector)
 Prepares iteration over valid neighbouring pixels from a linear index, excluding the origin.
 
AdjacencyRelationgetNeighborPixelsForward (int row, int col)
 Prepares forward-only neighbour iteration at (row, col).
 
AdjacencyRelationgetNeighborPixelsForward (int indexVector)
 Prepares forward-only neighbour iteration from a linear index.
 
bool isAdjacent (int p, int q) const noexcept
 Tests adjacency between two linear pixel indices.
 
bool isAdjacent (int px, int py, int qx, int qy) const noexcept
 Tests adjacency between two pixel coordinates.
 
double getRadius () const
 Returns the configured neighbourhood radius.
 
bool is4connectivity () const
 Returns true when the stencil represents 4-connectivity.
 
bool is8connectivity () const
 Returns true when the stencil represents 8-connectivity.
 
bool isBorderDomainImage (int index)
 Returns whether a linear pixel index lies on the image border.
 
bool isBorderDomainImage (int row, int col)
 Returns whether (row, col) lies on the image border.
 
int getOffsetRow (int index)
 Returns the row offset stored at stencil position index.
 
int getOffsetCol (int index)
 Returns the column offset stored at stencil position index.
 
IteratorAdjacency begin ()
 Returns the beginning of the current traversal.
 
IteratorAdjacency end ()
 Returns the end sentinel of the current traversal.
 

Detailed Description

Two-dimensional adjacency relation with configurable radius and efficient iteration.

AdjacencyRelation stores a reusable stencil of offsets for a regular image grid. The stencil can be traversed either fully or in forward-only mode, which exposes only one directed half of the neighbourhood and is therefore convenient when unique undirected edges are needed.

Coordinates use (row, col) order for row-major image domains. Linear pixel ids use row * numCols + col. Iteration methods mutate an internal cursor, so one AdjacencyRelation object should not be traversed by multiple active ranges at the same time.

Definition at line 28 of file AdjacencyRelation.hpp.

Constructor & Destructor Documentation

◆ AdjacencyRelation()

mmcfilters::AdjacencyRelation::AdjacencyRelation ( int  numRows,
int  numCols,
double  radius 
)
inline

Builds an adjacency relation for a numRows by numCols image.

Parameters
numRowsNumber of image rows.
numColsNumber of image columns.
radiusRadius of the neighbourhood stencil. 1.0 gives 4-connectivity and 1.5 gives 8-connectivity on the integer grid.

Definition at line 55 of file AdjacencyRelation.hpp.

Member Function Documentation

◆ begin()

IteratorAdjacency mmcfilters::AdjacencyRelation::begin ( )
inline

Returns the beginning of the current traversal.

Call one of the get*Pixels methods before requesting begin().

Definition at line 466 of file AdjacencyRelation.hpp.

◆ end()

IteratorAdjacency mmcfilters::AdjacencyRelation::end ( )
inline

Returns the end sentinel of the current traversal.

Definition at line 473 of file AdjacencyRelation.hpp.

◆ getAdjPixels() [1/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getAdjPixels ( int  indexVector)
inline

Prepares iteration over adjacent pixels from a linear index, including the origin.

Parameters
indexVectorRow-major linear pixel index.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf indexVector maps outside the image domain.

Definition at line 250 of file AdjacencyRelation.hpp.

◆ getAdjPixels() [2/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getAdjPixels ( int  row,
int  col 
)
inline

Prepares iteration over adjacent pixels, including the origin.

Parameters
rowZero-based row coordinate inside the image domain.
colZero-based column coordinate inside the image domain.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf (row, col) is outside the image domain.

Definition at line 231 of file AdjacencyRelation.hpp.

◆ getNeighborPixels() [1/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getNeighborPixels ( int  indexVector)
inline

Prepares iteration over valid neighbouring pixels from a linear index, excluding the origin.

Parameters
indexVectorRow-major linear pixel index.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf indexVector maps outside the image domain.

Definition at line 281 of file AdjacencyRelation.hpp.

◆ getNeighborPixels() [2/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getNeighborPixels ( int  row,
int  col 
)
inline

Prepares iteration over valid neighbouring pixels, excluding the origin.

Parameters
rowZero-based row coordinate inside the image domain.
colZero-based column coordinate inside the image domain.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf (row, col) is outside the image domain.

Definition at line 263 of file AdjacencyRelation.hpp.

◆ getNeighborPixelsForward() [1/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getNeighborPixelsForward ( int  indexVector)
inline

Prepares forward-only neighbour iteration from a linear index.

Parameters
indexVectorRow-major linear pixel index.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf indexVector maps outside the image domain.

Definition at line 314 of file AdjacencyRelation.hpp.

◆ getNeighborPixelsForward() [2/2]

AdjacencyRelation & mmcfilters::AdjacencyRelation::getNeighborPixelsForward ( int  row,
int  col 
)
inline

Prepares forward-only neighbour iteration at (row, col).

Only one directed half of the neighbourhood is emitted: neighbours whose offset has dy > 0, or dy == 0 && dx > 0.

Parameters
rowZero-based row coordinate inside the image domain.
colZero-based column coordinate inside the image domain.
Returns
This adjacency relation configured as a range.
Exceptions
std::out_of_rangeIf (row, col) is outside the image domain.

Definition at line 296 of file AdjacencyRelation.hpp.

◆ getNumCols()

int mmcfilters::AdjacencyRelation::getNumCols ( ) const
inlinenoexcept

Returns the number of columns in the attached image domain.

Definition at line 219 of file AdjacencyRelation.hpp.

◆ getNumRows()

int mmcfilters::AdjacencyRelation::getNumRows ( ) const
inlinenoexcept

Returns the number of rows in the attached image domain.

Definition at line 212 of file AdjacencyRelation.hpp.

◆ getOffsetCol()

int mmcfilters::AdjacencyRelation::getOffsetCol ( int  index)
inline

Returns the column offset stored at stencil position index.

The method does not perform bounds checking.

Definition at line 396 of file AdjacencyRelation.hpp.

◆ getOffsetRow()

int mmcfilters::AdjacencyRelation::getOffsetRow ( int  index)
inline

Returns the row offset stored at stencil position index.

The method does not perform bounds checking.

Definition at line 387 of file AdjacencyRelation.hpp.

◆ getRadius()

double mmcfilters::AdjacencyRelation::getRadius ( ) const
inline

Returns the configured neighbourhood radius.

Definition at line 348 of file AdjacencyRelation.hpp.

◆ getSize()

int mmcfilters::AdjacencyRelation::getSize ( ) const
inline

Returns the number of offsets in the current stencil.

The count includes the central origin offset at stencil position 0.

Definition at line 205 of file AdjacencyRelation.hpp.

◆ is4connectivity()

bool mmcfilters::AdjacencyRelation::is4connectivity ( ) const
inline

Returns true when the stencil represents 4-connectivity.

Definition at line 355 of file AdjacencyRelation.hpp.

◆ is8connectivity()

bool mmcfilters::AdjacencyRelation::is8connectivity ( ) const
inline

Returns true when the stencil represents 8-connectivity.

Definition at line 360 of file AdjacencyRelation.hpp.

◆ isAdjacent() [1/2]

bool mmcfilters::AdjacencyRelation::isAdjacent ( int  p,
int  q 
) const
inlinenoexcept

Tests adjacency between two linear pixel indices.

The central pixel is adjacent to itself because the radius test includes a zero-length offset.

Definition at line 325 of file AdjacencyRelation.hpp.

◆ isAdjacent() [2/2]

bool mmcfilters::AdjacencyRelation::isAdjacent ( int  px,
int  py,
int  qx,
int  qy 
) const
inlinenoexcept

Tests adjacency between two pixel coordinates.

Coordinates are given as (x, y) pairs, where x is the column and y is the row. The method only applies the radius test; it does not check whether either coordinate lies inside the configured image domain.

Definition at line 339 of file AdjacencyRelation.hpp.

◆ isBorderDomainImage() [1/2]

bool mmcfilters::AdjacencyRelation::isBorderDomainImage ( int  index)
inline

Returns whether a linear pixel index lies on the image border.

The index is interpreted in row-major order. No explicit bounds check is performed before converting the index to (row, col).

Definition at line 368 of file AdjacencyRelation.hpp.

◆ isBorderDomainImage() [2/2]

bool mmcfilters::AdjacencyRelation::isBorderDomainImage ( int  row,
int  col 
)
inline

Returns whether (row, col) lies on the image border.

The method assumes coordinates are inside the image domain.

Definition at line 378 of file AdjacencyRelation.hpp.

◆ nextValid()

int mmcfilters::AdjacencyRelation::nextValid ( )
inline

Advances to the next valid offset under the current bounds and mode.

Returns
Index of the next valid offset, or getSize() if none remain.

Definition at line 181 of file AdjacencyRelation.hpp.


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