ITK  6.0.0
Insight Toolkit
Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | List of all members
itk::ConnectedImageNeighborhoodShape< VImageDimension > Class Template Reference

#include <itkConnectedImageNeighborhoodShape.h>

Detailed Description

template<unsigned int VImageDimension>
class itk::ConnectedImageNeighborhoodShape< VImageDimension >

Connected image-neighborhood shape, based on the topological property of pixel connectivity. Eases creating a sequence of offsets to construct a ShapedImageNeighborhoodRange object. Can also be used to specify the shape of a ShapedNeighborhoodIterator, using its ActivateOffset member function.

This shape class supports generating offsets in colexicographic order. Which means that, for example, a sequence of generated offsets for a 2-dimensional shape will have offset {1, 0} before offset {0, 1}. This order was chosen because it is usually in agreement with the order of the corresponding neighbor pixels, as stored in the internal image buffer.

The following example generates the offsets for a 3-dimensional 18-connected neighborhood shape, including the center pixel, and asserts that the result is as expected:

size_t maximumCityblockDistance = 2;
bool includeCenterPixel = true;
ConnectedImageNeighborhoodShape<3> shape{ maximumCityblockDistance, includeCenterPixel };
std::vector<Offset<3>> offsets = GenerateImageNeighborhoodOffsets(shape);
assert(offsets.size() == 19);
assert(offsets == std::vector<Offset<3>>(
{
{{0, -1, -1}}, {{-1, 0, -1}}, {{0, 0, -1}},
{{1, 0, -1}}, {{0, 1, -1}}, {{-1, -1, 0}},
{{0, -1, 0}}, {{1, -1, 0}}, {{-1, 0, 0}},
{{0, 0, 0}},
{{1, 0, 0}}, {{-1, 1, 0}}, {{0, 1, 0}},
{{1, 1, 0}}, {{0, -1, 1}}, {{-1, 0, 1}},
{{0, 0, 1}}, {{1, 0, 1}}, {{0, 1, 1}}
}));

The following code shows how to create 4-connected, 8-connected, 6-connected, 18-connected, and 26-connected neighborhood shapes:

// 2-dimensional:
ConnectedImageNeighborhoodShape<2> _4_connectedShape{ 1, includeCenterPixel };
ConnectedImageNeighborhoodShape<2> _8_connectedShape{ 2, includeCenterPixel };
// 3-dimensional:
ConnectedImageNeighborhoodShape<3> _6_connectedShape{ 1, includeCenterPixel };
ConnectedImageNeighborhoodShape<3> _18_connectedShape{ 2, includeCenterPixel };
ConnectedImageNeighborhoodShape<3> _26_connectedShape{ 3, includeCenterPixel };
Author
Niels Dekker, LKEB, Leiden University Medical Center
See also
ShapedImageNeighborhoodRange
ShapedNeighborhoodIterator

Definition at line 87 of file itkConnectedImageNeighborhoodShape.h.

+ Collaboration diagram for itk::ConnectedImageNeighborhoodShape< VImageDimension >:

Public Member Functions

constexpr vcl_size_t GetNumberOfOffsets () const noexcept
 
constexpr ConnectedImageNeighborhoodShape (const vcl_size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
 
void FillOffsets (Offset< ImageDimension > *const offsets) const noexcept
 

Static Public Attributes

static constexpr unsigned int ImageDimension = VImageDimension
 

Static Private Member Functions

static constexpr uintmax_t CalculateBinomialCoefficient (const uintmax_t n, const uintmax_t k) noexcept
 
static constexpr vcl_size_t CalculateNumberOfConnectedNeighbors (const vcl_size_t maximumCityblockDistance) noexcept
 
static constexpr vcl_size_t CalculateNumberOfHypercubesOnBoundaryOfCube (const vcl_size_t m, const vcl_size_t n) noexcept
 
static constexpr uintmax_t CalculatePowerOfTwo (const vcl_size_t n) noexcept
 
static constexpr uintmax_t CalculateSum (const uintmax_t a, const uintmax_t b) noexcept
 
static constexpr vcl_size_t CalculateSumOfNumberOfHypercubesOnBoundaryOfCube (const vcl_size_t i, const vcl_size_t m) noexcept
 
static constexpr vcl_size_t CalculateNumberOfOffsets (const vcl_size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
 

Private Attributes

bool m_IncludeCenterPixel
 
vcl_size_t m_MaximumCityblockDistance
 
vcl_size_t m_NumberOfOffsets
 

Constructor & Destructor Documentation

◆ ConnectedImageNeighborhoodShape()

template<unsigned int VImageDimension>
constexpr itk::ConnectedImageNeighborhoodShape< VImageDimension >::ConnectedImageNeighborhoodShape ( const vcl_size_t  maximumCityblockDistance,
const bool  includeCenterPixel 
)
inlineexplicitconstexprnoexcept

Constructs a connected image-neighborhood shape. Its offsets contain only the offset values -1, 0, and 1. The parameter 'maximumCityblockDistance' specifies the maximum city-block distance (Manhattan distance) between the center pixel and the connected neighbor pixel. This distance measure corresponds to the number of non-zero values of an offset. For example, in a 3-dimensional neighborhood, offset {1,0,0}, {0,1,0}, and {0,0,1} have distance = 1 to the center, while offset {1,1,1} has distance = 3. The parameter 'includeCenterPixel' specifies whether or not the center pixel (offset zero) should be included with the offsets for this shape.

Definition at line 104 of file itkConnectedImageNeighborhoodShape.h.

Member Function Documentation

◆ CalculateBinomialCoefficient()

template<unsigned int VImageDimension>
static constexpr uintmax_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateBinomialCoefficient ( const uintmax_t  n,
const uintmax_t  k 
)
inlinestaticconstexprprivatenoexcept

◆ CalculateNumberOfConnectedNeighbors()

template<unsigned int VImageDimension>
static constexpr vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfConnectedNeighbors ( const vcl_size_t  maximumCityblockDistance)
inlinestaticconstexprprivatenoexcept

◆ CalculateNumberOfHypercubesOnBoundaryOfCube()

template<unsigned int VImageDimension>
static constexpr vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfHypercubesOnBoundaryOfCube ( const vcl_size_t  m,
const vcl_size_t  n 
)
inlinestaticconstexprprivatenoexcept

◆ CalculateNumberOfOffsets()

template<unsigned int VImageDimension>
static constexpr vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfOffsets ( const vcl_size_t  maximumCityblockDistance,
const bool  includeCenterPixel 
)
inlinestaticconstexprprivatenoexcept

Calculates the number of offsets needed for this shape.

Definition at line 249 of file itkConnectedImageNeighborhoodShape.h.

References itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfConnectedNeighbors().

◆ CalculatePowerOfTwo()

template<unsigned int VImageDimension>
static constexpr uintmax_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculatePowerOfTwo ( const vcl_size_t  n)
inlinestaticconstexprprivatenoexcept

◆ CalculateSum()

template<unsigned int VImageDimension>
static constexpr uintmax_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateSum ( const uintmax_t  a,
const uintmax_t  b 
)
inlinestaticconstexprprivatenoexcept

◆ CalculateSumOfNumberOfHypercubesOnBoundaryOfCube()

template<unsigned int VImageDimension>
static constexpr vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateSumOfNumberOfHypercubesOnBoundaryOfCube ( const vcl_size_t  i,
const vcl_size_t  m 
)
inlinestaticconstexprprivatenoexcept

◆ FillOffsets()

template<unsigned int VImageDimension>
void itk::ConnectedImageNeighborhoodShape< VImageDimension >::FillOffsets ( Offset< ImageDimension > *const  offsets) const
inlinenoexcept

◆ GetNumberOfOffsets()

template<unsigned int VImageDimension>
constexpr vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::GetNumberOfOffsets ( ) const
inlineconstexprnoexcept

Returns the number of offsets needed for this shape.

Definition at line 115 of file itkConnectedImageNeighborhoodShape.h.

References itk::ConnectedImageNeighborhoodShape< VImageDimension >::m_NumberOfOffsets.

Referenced by itk::GenerateConnectedImageNeighborhoodShapeOffsets().

Member Data Documentation

◆ ImageDimension

template<unsigned int VImageDimension>
constexpr unsigned int itk::ConnectedImageNeighborhoodShape< VImageDimension >::ImageDimension = VImageDimension
staticconstexpr

◆ m_IncludeCenterPixel

template<unsigned int VImageDimension>
bool itk::ConnectedImageNeighborhoodShape< VImageDimension >::m_IncludeCenterPixel
private

◆ m_MaximumCityblockDistance

template<unsigned int VImageDimension>
vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::m_MaximumCityblockDistance
private

◆ m_NumberOfOffsets

template<unsigned int VImageDimension>
vcl_size_t itk::ConnectedImageNeighborhoodShape< VImageDimension >::m_NumberOfOffsets
private

The documentation for this class was generated from the following file:
itk::GenerateImageNeighborhoodOffsets
std::vector< Offset< TImageNeighborhoodShape::ImageDimension > > GenerateImageNeighborhoodOffsets(const TImageNeighborhoodShape &shape)
Definition: itkImageNeighborhoodOffsets.h:31