dip::NeighborList class

Defines the neighborhood of a pixel as a set of coordinates, with optionally their distance.

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 NeighborList given the image dimensionality and a dip::Metric.

Classes

class Iterator
Iterates over the neighbors in the NeighborList.

Functions

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.
template<typename T>
auto CopyDistances() const -> std::vector<T>
Returns an array with the distances to each of the neighbors in the list.
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 ImageIterator and the like would. procDim must 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 ImageIterator and the like would. procDim must be the iterator’s processing dimension.
auto SelectBackward(dip::uint procDim = 0) const -> dip::NeighborList
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.
auto SelectForward(dip::uint procDim = 0) const -> dip::NeighborList
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.
auto Size() const -> dip::uint
Returns the number of neighbors.
auto Dimensionality() const -> dip::uint
Returns the neighborhood dimensionality
auto Border() const -> dip::UnsignedArray
Returns the number of pixels, along each dimension, that the neighborhood extends outside of its central pixel.
auto begin() const -> dip::NeighborList::Iterator
A forward iterator to the first neighbor
auto end() const -> dip::NeighborList::Iterator
A forward iterator to one past the last neighbor
auto Coordinates(dip::uint index) const -> dip::IntegerArray const&
Retrieve neighbor coordinates by index
auto Distance(dip::uint index) const -> dip::dfloat
Retrieve neighbor distance by index
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