ITK  5.0.0
Insight Segmentation and Registration Toolkit
Public Member Functions | Static Public Attributes | List of all members
itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension > Class Template Reference

#include <itkConnectedImageNeighborhoodShape.h>

Detailed Description

template<unsigned int VImageDimension>
class itk::Experimental::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:

std::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 99 of file itkConnectedImageNeighborhoodShape.h.

Public Member Functions

constexpr std::vcl_size_t GetNumberOfOffsets () const noexcept
 
constexpr ConnectedImageNeighborhoodShape (const std::vcl_size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
 

Static Public Attributes

static constexpr unsigned int ImageDimension = VImageDimension
 
std::vcl_size_t m_MaximumCityblockDistance
 
bool m_IncludeCenterPixel
 
std::vcl_size_t m_NumberOfOffsets
 
void FillOffsets (Offset< ImageDimension > *const offsets) const noexcept
 
static constexpr std::uintmax_t CalculateSum (const std::uintmax_t a, const std::uintmax_t b) noexcept
 
static constexpr std::uintmax_t CalculateProduct (const std::uintmax_t a, const std::uintmax_t b) noexcept
 
static constexpr std::uintmax_t CalculatePowerOfTwo (const std::vcl_size_t n) noexcept
 
static constexpr std::uintmax_t CalculatePowerOfThree (const std::vcl_size_t n) noexcept
 
static constexpr std::uintmax_t CalculateBinomialCoefficient (const std::uintmax_t n, const std::uintmax_t k) noexcept
 
static constexpr std::vcl_size_t CalculateNumberOfHypercubesOnBoundaryOfCube (const std::vcl_size_t m, const std::vcl_size_t n) noexcept
 
static constexpr std::vcl_size_t CalculateSumOfNumberOfHypercubesOnBoundaryOfCube (const std::vcl_size_t i, const std::vcl_size_t m) noexcept
 
static constexpr std::vcl_size_t CalculateNumberOfConnectedNeighbors (const std::vcl_size_t maximumCityblockDistance) noexcept
 
static constexpr std::vcl_size_t CalculateNumberOfOffsets (const std::vcl_size_t maximumCityblockDistance, const bool includeCenterPixel) noexcept
 
template<unsigned int VImageDimensionOfFriend, std::vcl_size_t VMaximumCityblockDistance, bool VIncludeCenterPixel>
std::array< Offset
< VImageDimensionOfFriend >
, ConnectedImageNeighborhoodShape
< VImageDimensionOfFriend >
::CalculateNumberOfOffsets(VMaximumCityblockDistance,
VIncludeCenterPixel)> 
GenerateConnectedImageNeighborhoodShapeOffsets () noexcept
 

Constructor & Destructor Documentation

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

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 116 of file itkConnectedImageNeighborhoodShape.h.

Member Function Documentation

template<unsigned int VImageDimension>
static constexpr std::uintmax_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateBinomialCoefficient ( const std::uintmax_t  n,
const std::uintmax_t  k 
)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
static constexpr std::vcl_size_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfConnectedNeighbors ( const std::vcl_size_t  maximumCityblockDistance)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
static constexpr std::vcl_size_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfHypercubesOnBoundaryOfCube ( const std::vcl_size_t  m,
const std::vcl_size_t  n 
)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
static constexpr std::vcl_size_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfOffsets ( const std::vcl_size_t  maximumCityblockDistance,
const bool  includeCenterPixel 
)
inlinestaticprivatenoexcept

Calculates the number of offsets needed for this shape.

Definition at line 288 of file itkConnectedImageNeighborhoodShape.h.

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

template<unsigned int VImageDimension>
static constexpr std::uintmax_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculatePowerOfThree ( const std::vcl_size_t  n)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
static constexpr std::uintmax_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculatePowerOfTwo ( const std::vcl_size_t  n)
inlinestaticprivatenoexcept

Fills the specified buffer with the offsets for a neighborhood of this shape.

Definition at line 214 of file itkConnectedImageNeighborhoodShape.h.

References ITK_X_ASSERT.

Referenced by itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateNumberOfHypercubesOnBoundaryOfCube().

template<unsigned int VImageDimension>
static constexpr std::uintmax_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateProduct ( const std::uintmax_t  a,
const std::uintmax_t  b 
)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
static constexpr std::uintmax_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateSum ( const std::uintmax_t  a,
const std::uintmax_t  b 
)
inlinestaticprivatenoexcept

Fills the specified buffer with the offsets for a neighborhood of this shape.

Definition at line 192 of file itkConnectedImageNeighborhoodShape.h.

References ITK_X_ASSERT.

Referenced by itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateSumOfNumberOfHypercubesOnBoundaryOfCube().

template<unsigned int VImageDimension>
static constexpr std::vcl_size_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::CalculateSumOfNumberOfHypercubesOnBoundaryOfCube ( const std::vcl_size_t  i,
const std::vcl_size_t  m 
)
inlinestaticprivatenoexcept
template<unsigned int VImageDimension>
void itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::FillOffsets ( Offset< ImageDimension > *const  offsets) const
inlinenoexcept
template<unsigned int VImageDimension>
constexpr std::vcl_size_t itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::GetNumberOfOffsets ( ) const
inlinenoexcept

Friends And Related Function Documentation

template<unsigned int VImageDimension>
template<unsigned int VImageDimensionOfFriend, std::vcl_size_t VMaximumCityblockDistance, bool VIncludeCenterPixel>
std::array< Offset<VImageDimensionOfFriend>, ConnectedImageNeighborhoodShape<VImageDimensionOfFriend>::CalculateNumberOfOffsets(VMaximumCityblockDistance, VIncludeCenterPixel)> GenerateConnectedImageNeighborhoodShapeOffsets ( )
friend

Generates the offsets for a connected image neighborhood shape.

Definition at line 311 of file itkConnectedImageNeighborhoodShape.h.

Member Data Documentation

template<unsigned int VImageDimension>
constexpr unsigned int itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::ImageDimension = VImageDimension
static
template<unsigned int VImageDimension>
bool itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::m_IncludeCenterPixel
private

Fills the specified buffer with the offsets for a neighborhood of this shape.

Definition at line 184 of file itkConnectedImageNeighborhoodShape.h.

Referenced by itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::FillOffsets().

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

Fills the specified buffer with the offsets for a neighborhood of this shape.

Definition at line 180 of file itkConnectedImageNeighborhoodShape.h.

Referenced by itk::Experimental::ConnectedImageNeighborhoodShape< VImageDimension >::FillOffsets().

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

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