19#ifndef itkShapedImageNeighborhoodRange_h
20#define itkShapedImageNeighborhoodRange_h
90template <
typename TImage,
91 typename TImageNeighborhoodPixelAccessPolicy = ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy<TImage>>
108 template <
typename T>
110 Test(
typename T::PixelAccessParameterType *);
112 template <
typename T>
119 !std::is_same_v<decltype(Test<TImageNeighborhoodPixelAccessPolicy>(
nullptr)),
120 decltype(Test<TImageNeighborhoodPixelAccessPolicy>())>;
124 template <
typename TPolicy,
bool VPolicyHasPixelAccessParameterType = CheckPolicy::HasPixelAccessParameterType>
127 using Type =
typename TPolicy::PixelAccessParameterType;
131 template <
typename TPolicy>
161 template <
bool VIsConst,
typename TDummy =
void>
167 template <
typename TDummy>
189 const TImageNeighborhoodPixelAccessPolicy & pixelAccessPolicy) noexcept
191 , m_PixelAccessPolicy{ pixelAccessPolicy }
197 , m_PixelAccessPolicy{ pixelProxy.m_PixelAccessPolicy }
207 template <
typename TDummy>
231 const TImageNeighborhoodPixelAccessPolicy & pixelAccessPolicy) noexcept
233 , m_PixelAccessPolicy{ pixelAccessPolicy }
262 const auto lhsPixelValue = lhs.m_PixelAccessPolicy.GetPixelValue(lhs.m_ImageBufferPointer);
263 const auto rhsPixelValue = rhs.m_PixelAccessPolicy.GetPixelValue(rhs.m_ImageBufferPointer);
266 lhs.m_PixelAccessPolicy.SetPixelValue(lhs.m_ImageBufferPointer, rhsPixelValue);
267 rhs.m_PixelAccessPolicy.SetPixelValue(rhs.m_ImageBufferPointer, lhsPixelValue);
284 template <
bool VIsConst>
352 return TImageNeighborhoodPixelAccessPolicy{
357 template <
typename TPixelAccessParameter>
358 TImageNeighborhoodPixelAccessPolicy
361 static_assert(std::is_same_v<TPixelAccessParameter, OptionalPixelAccessParameterType>,
362 "This helper function should only be used for OptionalPixelAccessParameterType!");
363 static_assert(!std::is_same_v<TPixelAccessParameter, EmptyPixelAccessParameter>,
364 "EmptyPixelAccessParameter indicates that there is no pixel access parameter specified!");
365 return TImageNeighborhoodPixelAccessPolicy{
390 template <
bool VIsArgumentConst,
typename = std::enable_if_t<VIsConst && !VIsArgumentConst>>
466 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
467 assert(lhs.m_ImageSize == rhs.m_ImageSize);
468 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
471 return lhs.m_CurrentOffset == rhs.m_CurrentOffset;
480 return !(lhs == rhs);
488 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
489 assert(lhs.m_ImageSize == rhs.m_ImageSize);
490 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
493 return lhs.m_CurrentOffset < rhs.m_CurrentOffset;
546 assert(lhs.m_ImageBufferPointer == rhs.m_ImageBufferPointer);
547 assert(lhs.m_ImageSize == rhs.m_ImageSize);
548 assert(lhs.m_OffsetTable == rhs.m_OffsetTable);
551 return lhs.m_CurrentOffset - rhs.m_CurrentOffset;
597 :
m_Index(imageRegion.GetIndex())
598 ,
m_Size(imageRegion.GetSize())
608 index1[i] -= index2[i];
661 const size_t numberOfNeigborhoodPixels,
676 assert(offsetTable !=
nullptr);
694 template <
typename TContainerOfOffsets>
697 const TContainerOfOffsets & shapeOffsets,
701 std::data(shapeOffsets),
702 std::size(shapeOffsets),
703 optionalPixelAccessParameter }
733 return this->
begin();
795 assert(n < this->
size());
796 assert(n <=
static_cast<size_t>(std::numeric_limits<ptrdiff_t>::max()));
799 return this->
begin()[
static_cast<ptrdiff_t
>(n)];
static constexpr bool HasPixelAccessParameterType
static int Test(typename T::PixelAccessParameterType *)
const TImageNeighborhoodPixelAccessPolicy m_PixelAccessPolicy
PixelProxy(const PixelProxy &) noexcept=default
PixelProxy & operator=(const PixelProxy &pixelProxy) noexcept
PixelProxy(InternalPixelType *const imageBufferPointer, const TImageNeighborhoodPixelAccessPolicy &pixelAccessPolicy) noexcept
PixelProxy & operator=(const PixelType &pixelValue) noexcept
InternalPixelType *const m_ImageBufferPointer
const TImageNeighborhoodPixelAccessPolicy m_PixelAccessPolicy
PixelProxy & operator=(const PixelProxy &)=delete
PixelProxy(const PixelProxy< false > &pixelProxy) noexcept
const InternalPixelType *const m_ImageBufferPointer
PixelProxy(const InternalPixelType *const imageBufferPointer, const TImageNeighborhoodPixelAccessPolicy &pixelAccessPolicy) noexcept
PixelProxy(const PixelProxy &) noexcept=default
friend difference_type operator-(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
ptrdiff_t difference_type
QualifiedIterator(QualifiedInternalPixelType *const imageBufferPointer, const ImageSizeType &imageSize, const OffsetType &offsetTable, const NeighborhoodAccessorFunctorType &neighborhoodAccessor, const OptionalPixelAccessParameterType optionalPixelAccessParameter, const IndexType &relativeLocation, const OffsetType *const offset) noexcept
NeighborhoodAccessorFunctorType m_NeighborhoodAccessor
friend QualifiedIterator & operator-=(QualifiedIterator &it, const difference_type n) noexcept
friend bool operator!=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
friend QualifiedIterator operator+(const difference_type n, QualifiedIterator it) noexcept
friend QualifiedIterator & operator+=(QualifiedIterator &it, const difference_type n) noexcept
ImageSizeType m_ImageSize
std::random_access_iterator_tag iterator_category
reference operator*() const noexcept
friend QualifiedIterator operator-(QualifiedIterator it, const difference_type n) noexcept
QualifiedIterator operator++(int) noexcept
std::conditional_t< VIsConst, const ImageType, ImageType > QualifiedImageType
std::conditional_t< IsImageTypeConst, const PixelType, PixelType > QualifiedPixelType
const OffsetType * m_CurrentOffset
IndexType m_RelativeLocation
QualifiedIterator & operator++() noexcept
friend bool operator==(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
TImageNeighborhoodPixelAccessPolicy CreatePixelAccessPolicy(EmptyPixelAccessParameter) const
QualifiedIterator(const QualifiedIterator< VIsArgumentConst > &arg) noexcept
QualifiedIterator & operator--() noexcept
QualifiedIterator operator--(int) noexcept
friend bool operator<=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
QualifiedIterator()=default
friend QualifiedIterator operator+(QualifiedIterator it, const difference_type n) noexcept
QualifiedPixelType * pointer
friend bool operator<(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
OptionalPixelAccessParameterType m_OptionalPixelAccessParameter
QualifiedInternalPixelType * m_ImageBufferPointer
TImageNeighborhoodPixelAccessPolicy CreatePixelAccessPolicy(const TPixelAccessParameter pixelAccessParameter) const
static constexpr bool IsImageTypeConst
friend bool operator>=(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
reference operator[](const difference_type n) const noexcept
friend bool operator>(const QualifiedIterator &lhs, const QualifiedIterator &rhs) noexcept
std::conditional_t< IsImageTypeConst, const InternalPixelType, InternalPixelType > QualifiedInternalPixelType
typename TImage::RegionType ImageRegionType
QualifiedIterator< IsImageTypeConst > iterator
typename TImage::InternalPixelType InternalPixelType
std::reverse_iterator< iterator > reverse_iterator
ShapedImageNeighborhoodRange()=default
typename TImage::ImageDimensionType ImageDimensionType
RegionData m_BufferedRegionData
static constexpr bool IsImageTypeConst
typename TImage::PixelType PixelType
void SetLocation(const IndexType &location) noexcept
typename TImage::SizeType ImageSizeType
static constexpr ImageDimensionType ImageDimension
const_reverse_iterator crend() const noexcept
vcl_size_t size() const noexcept
ShapedImageNeighborhoodRange(ImageType &image, const IndexType &location, const TContainerOfOffsets &shapeOffsets, const OptionalPixelAccessParameterType optionalPixelAccessParameter={})
reverse_iterator rbegin() const noexcept
const_iterator cbegin() const noexcept
NeighborhoodAccessorFunctorType m_NeighborhoodAccessor
typename TImage::IndexType IndexType
typename OptionalPixelAccessParameter< TImageNeighborhoodPixelAccessPolicy >::Type OptionalPixelAccessParameterType
iterator end() const noexcept
reverse_iterator rend() const noexcept
const_reverse_iterator crbegin() const noexcept
ShapedImageNeighborhoodRange(ImageType &image, const IndexType &location, const OffsetType *const shapeOffsets, const vcl_size_t numberOfNeigborhoodPixels, const OptionalPixelAccessParameterType optionalPixelAccessParameter={})
typename TImage::SizeValueType ImageSizeValueType
typename TImage::IndexValueType IndexValueType
QualifiedInternalPixelType * m_ImageBufferPointer
const_iterator cend() const noexcept
void SubtractIndex(IndexType &index1, const IndexType &index2)
vcl_size_t m_NumberOfNeighborhoodPixels
typename TImage::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
IndexType m_RelativeLocation
std::conditional_t< IsImageTypeConst, const InternalPixelType, InternalPixelType > QualifiedInternalPixelType
QualifiedIterator< true > const_iterator
iterator begin() const noexcept
bool empty() const noexcept
const OffsetType * m_ShapeOffsets
OptionalPixelAccessParameterType m_OptionalPixelAccessParameter
std::reverse_iterator< const_iterator > const_reverse_iterator
QualifiedIterator< false >::reference operator[](const vcl_size_t n) const noexcept
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
ImageBaseType::SizeType SizeType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
void swap(Array< T > &a, Array< T > &b) noexcept
unsigned long SizeValueType
constexpr iterator begin()
typename TPolicy::PixelAccessParameterType Type
RegionData() noexcept=default