|
MorphologicalAttributeFilters
Public API documentation
|
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. | |
| AdjacencyRelation & | getAdjPixels (int row, int col) |
| Prepares iteration over adjacent pixels, including the origin. | |
| AdjacencyRelation & | getAdjPixels (int indexVector) |
| Prepares iteration over adjacent pixels from a linear index, including the origin. | |
| AdjacencyRelation & | getNeighborPixels (int row, int col) |
| Prepares iteration over valid neighbouring pixels, excluding the origin. | |
| AdjacencyRelation & | getNeighborPixels (int indexVector) |
| Prepares iteration over valid neighbouring pixels from a linear index, excluding the origin. | |
| AdjacencyRelation & | getNeighborPixelsForward (int row, int col) |
Prepares forward-only neighbour iteration at (row, col). | |
| AdjacencyRelation & | getNeighborPixelsForward (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. | |
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.
Builds an adjacency relation for a numRows by numCols image.
| numRows | Number of image rows. |
| numCols | Number of image columns. |
| radius | Radius 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.
|
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.
|
inline |
Returns the end sentinel of the current traversal.
Definition at line 473 of file AdjacencyRelation.hpp.
|
inline |
Prepares iteration over adjacent pixels from a linear index, including the origin.
| indexVector | Row-major linear pixel index. |
| std::out_of_range | If indexVector maps outside the image domain. |
Definition at line 250 of file AdjacencyRelation.hpp.
|
inline |
Prepares iteration over adjacent pixels, including the origin.
| row | Zero-based row coordinate inside the image domain. |
| col | Zero-based column coordinate inside the image domain. |
| std::out_of_range | If (row, col) is outside the image domain. |
Definition at line 231 of file AdjacencyRelation.hpp.
|
inline |
Prepares iteration over valid neighbouring pixels from a linear index, excluding the origin.
| indexVector | Row-major linear pixel index. |
| std::out_of_range | If indexVector maps outside the image domain. |
Definition at line 281 of file AdjacencyRelation.hpp.
|
inline |
Prepares iteration over valid neighbouring pixels, excluding the origin.
| row | Zero-based row coordinate inside the image domain. |
| col | Zero-based column coordinate inside the image domain. |
| std::out_of_range | If (row, col) is outside the image domain. |
Definition at line 263 of file AdjacencyRelation.hpp.
|
inline |
Prepares forward-only neighbour iteration from a linear index.
| indexVector | Row-major linear pixel index. |
| std::out_of_range | If indexVector maps outside the image domain. |
Definition at line 314 of file AdjacencyRelation.hpp.
|
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.
| row | Zero-based row coordinate inside the image domain. |
| col | Zero-based column coordinate inside the image domain. |
| std::out_of_range | If (row, col) is outside the image domain. |
Definition at line 296 of file AdjacencyRelation.hpp.
|
inlinenoexcept |
Returns the number of columns in the attached image domain.
Definition at line 219 of file AdjacencyRelation.hpp.
|
inlinenoexcept |
Returns the number of rows in the attached image domain.
Definition at line 212 of file AdjacencyRelation.hpp.
Returns the column offset stored at stencil position index.
The method does not perform bounds checking.
Definition at line 396 of file AdjacencyRelation.hpp.
Returns the row offset stored at stencil position index.
The method does not perform bounds checking.
Definition at line 387 of file AdjacencyRelation.hpp.
|
inline |
Returns the configured neighbourhood radius.
Definition at line 348 of file AdjacencyRelation.hpp.
|
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.
|
inline |
Returns true when the stencil represents 4-connectivity.
Definition at line 355 of file AdjacencyRelation.hpp.
|
inline |
Returns true when the stencil represents 8-connectivity.
Definition at line 360 of file AdjacencyRelation.hpp.
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.
|
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.
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.
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.
|
inline |
Advances to the next valid offset under the current bounds and mode.
getSize() if none remain. Definition at line 181 of file AdjacencyRelation.hpp.