ITK  5.2.0
Insight Toolkit
itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy_h
20 #define itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy_h
21 
22 #include "itkIndex.h"
23 #include "itkOffset.h"
24 #include "itkSize.h"
25 
26 namespace itk
27 {
28 
41 template <typename TImage>
43 {
44 private:
45  using NeighborhoodAccessorFunctorType = typename TImage::NeighborhoodAccessorFunctorType;
46  using PixelType = typename TImage::PixelType;
47  using InternalPixelType = typename TImage::InternalPixelType;
48 
49  using ImageDimensionType = typename TImage::ImageDimensionType;
50  static constexpr ImageDimensionType ImageDimension = TImage::ImageDimension;
51 
56 
57  // Index value to the image buffer, indexing the current pixel.
59 
60  // A reference to the accessor of the image.
62 
63 
64  // Private helper function. Clamps the index value between the interval
65  // [0 .. imageSizeValue>.
66  static IndexValueType
67  GetClampedIndexValue(const IndexValueType indexValue, const ImageSizeValueType imageSizeValue) ITK_NOEXCEPT
68  {
69  return (indexValue <= 0) ? 0
70  : (static_cast<ImageSizeValueType>(indexValue) < imageSizeValue)
71  ? indexValue
72  : static_cast<IndexValueType>(imageSizeValue - 1);
73  }
74 
75  // Private helper function. Calculates and returns the index value of the
76  // current pixel within the image buffer.
77  static IndexValueType
79  const OffsetType & offsetTable,
80  const IndexType & pixelIndex) ITK_NOEXCEPT
81  {
82  IndexValueType result = 0;
83 
84  for (ImageDimensionType i = 0; i < ImageDimension; ++i)
85  {
86  result += GetClampedIndexValue(pixelIndex[i], imageSize[i]) * offsetTable[i];
87  }
88  return result;
89  }
90 
91 public:
92  // Deleted member functions:
96 
97  // Explicitly-defaulted functions:
100  ITK_NOEXCEPT = default;
101 
105  const OffsetType & offsetTable,
106  const NeighborhoodAccessorFunctorType & neighborhoodAccessor,
107  const IndexType & pixelIndex) ITK_NOEXCEPT
108  : m_PixelIndexValue{ CalculatePixelIndexValue(imageSize, offsetTable, pixelIndex) }
109  , m_NeighborhoodAccessor(neighborhoodAccessor)
110  {}
112 
115  PixelType
116  GetPixelValue(const InternalPixelType * const imageBufferPointer) const ITK_NOEXCEPT
117  {
118  return m_NeighborhoodAccessor.Get(imageBufferPointer + m_PixelIndexValue);
119  }
120 
123  void
124  SetPixelValue(InternalPixelType * const imageBufferPointer, const PixelType & pixelValue) const ITK_NOEXCEPT
125  {
126  m_NeighborhoodAccessor.Set(imageBufferPointer + m_PixelIndexValue, pixelValue);
127  }
128 };
130 
131 } // namespace itk
132 
133 #endif
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::~ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
~ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy()=default
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:66
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageSizeValueType
SizeValueType ImageSizeValueType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:55
itk::Size< ImageDimension >
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::operator=
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy & operator=(const ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy &)=delete
itkOffset.h
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::m_PixelIndexValue
const IndexValueType m_PixelIndexValue
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:58
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::PixelType
typename TImage::PixelType PixelType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:46
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::CalculatePixelIndexValue
static IndexValueType CalculatePixelIndexValue(const ImageSizeType &imageSize, const OffsetType &offsetTable, const IndexType &pixelIndex) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:78
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy(const ImageSizeType &imageSize, const OffsetType &offsetTable, const NeighborhoodAccessorFunctorType &neighborhoodAccessor, const IndexType &pixelIndex) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:104
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:47
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::NeighborhoodAccessorFunctorType
typename TImage::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:45
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageDimensionType
typename TImage::ImageDimensionType ImageDimensionType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:49
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::GetPixelValue
PixelType GetPixelValue(const InternalPixelType *const imageBufferPointer) const noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:116
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageDimension
static constexpr ImageDimensionType ImageDimension
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:50
itkIndex.h
itk::Offset< ImageDimension >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:42
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy()=delete
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::m_NeighborhoodAccessor
const NeighborhoodAccessorFunctorType & m_NeighborhoodAccessor
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:61
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::SetPixelValue
void SetPixelValue(InternalPixelType *const imageBufferPointer, const PixelType &pixelValue) const noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:124
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::GetClampedIndexValue
static IndexValueType GetClampedIndexValue(const IndexValueType indexValue, const ImageSizeValueType imageSizeValue) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:67
itkSize.h