NeighborList class
Defines the neighborhood of a pixel as a set of coordinates, with optionally their distance.
Contents
An object of this class lists all neighbors in some neighborhood of a pixel, and is useful in dimensionality-agnostic algorithms that need direct access to each neighbor. The neighborhood can be specified as a connectivity (as in 4-connected, 26-connected, etc., except that we use an integer in a way that the concept extends readily to any dimensionality, see Connectivity). Alternatively, the neighborhood can be created as used in chamfer distance computation, where a larger neighborhood increases the accuracy of the computed distances.
If given a pixel size, the neighborhood list contains the magnitude of the physical distances to each neighbor. Otherwise, a default unit distance is substituted.
See dip::Kernel, dip::PixelTable, dip::Metric
Constructors, destructors, assignment and conversion operators
- NeighborList(dip::Metric const& metric, dip::uint dimensionality)
- Creates a
NeighborListgiven the image dimensionality and adip::Metric.
Classes
Functions
- auto begin() const -> dip::NeighborList::Iterator
- A forward iterator to the first neighbor
- auto Border() const -> dip::UnsignedArray
- Returns the number of pixels, along each dimension, that the neighborhood extends outside of its central pixel.
- auto ComputeOffsets(dip::IntegerArray const& strides) const -> dip::IntegerArray
- Returns an array with offsets corresponding to each of the neighbors in the list, given an image’s strides array.
- auto Coordinates(dip::uint index) const -> dip::IntegerArray const&
- Retrieve neighbor coordinates by index
-
template<typename T>auto CopyDistances() const -> std::vector<T>
- Returns an array with the distances to each of the neighbors in the list.
- auto Dimensionality() const -> dip::uint
- Returns the neighborhood dimensionality
- auto Distance(dip::uint index) const -> dip::dfloat
- Retrieve neighbor distance by index
- auto end() const -> dip::NeighborList::Iterator
- A forward iterator to one past the last neighbor
- auto FindBackward(dip::uint procDim = 0) const -> dip::BooleanArray
- Returns an array that is true for those neighbors that would be processed earlier
if processing as
ImageIteratorand the like would.procDimmust be the iterator’s processing dimension. - auto FindForward(dip::uint procDim = 0) const -> dip::BooleanArray
- Returns an array that is true for those neighbors that would be processed later
if processing as
ImageIteratorand the like would.procDimmust be the iterator’s processing dimension. - auto IsInImage(dip::uint index, dip::UnsignedArray const& coords, dip::UnsignedArray const& imsz) const -> bool
- Returns true if the neighbor by index is within the image
- auto SelectBackward(dip::uint procDim = 0) const -> dip::NeighborList
- Returns a new
NeighborListobject containing only those neighbors that would be processed earlier if processing asImageIteratorand the like would.procDimmust be the iterator’s processing dimension. - auto SelectForward(dip::uint procDim = 0) const -> dip::NeighborList
- Returns a new
NeighborListobject containing only those neighbors that would be processed later if processing asImageIteratorand the like would.procDimmust be the iterator’s processing dimension. - auto Size() const -> dip::uint
- Returns the number of neighbors.
Function documentation
NeighborList( dip::Metric const& metric, dip::uint dimensionality)
Creates a NeighborList given the image dimensionality and a dip::Metric.
dip::IntegerArray ComputeOffsets( dip::IntegerArray const& strides) const
Returns an array with offsets corresponding to each of the neighbors in the list, given an image’s strides array.
template<typename T>
std::vector<T>
CopyDistances(
) const
Returns an array with the distances to each of the neighbors in the list.
dip::BooleanArray FindBackward( dip::uint procDim = 0) const
Returns an array that is true for those neighbors that would be processed earlier
if processing as ImageIterator and the like would. procDim must be the iterator’s processing dimension.
dip::BooleanArray FindForward( dip::uint procDim = 0) const
Returns an array that is true for those neighbors that would be processed later
if processing as ImageIterator and the like would. procDim must be the iterator’s processing dimension.
dip::NeighborList SelectBackward( dip::uint procDim = 0) const
Returns a new NeighborList object containing only those neighbors that would be processed earlier
if processing as ImageIterator and the like would. procDim must be the iterator’s processing dimension.
dip::NeighborList SelectForward( dip::uint procDim = 0) const
Returns a new NeighborList object containing only those neighbors that would be processed later
if processing as ImageIterator and the like would. procDim must be the iterator’s processing dimension.
dip::uint Dimensionality( ) const
Returns the neighborhood dimensionality
dip::UnsignedArray Border( ) const
Returns the number of pixels, along each dimension, that the neighborhood extends outside of its central pixel.
dip::NeighborList::Iterator begin( ) const
A forward iterator to the first neighbor
dip::NeighborList::Iterator end( ) const
A forward iterator to one past the last neighbor
dip::IntegerArray const& Coordinates( dip::uint index) const
Retrieve neighbor coordinates by index
dip::dfloat Distance( dip::uint index) const
Retrieve neighbor distance by index
bool IsInImage( dip::uint index, dip::UnsignedArray const& coords, dip::UnsignedArray const& imsz) const
Returns true if the neighbor by index is within the image