ITK  5.1.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 namespace Experimental
29 {
30 
43 template <typename TImage>
45 {
46 private:
47  using NeighborhoodAccessorFunctorType = typename TImage::NeighborhoodAccessorFunctorType;
48  using PixelType = typename TImage::PixelType;
49  using InternalPixelType = typename TImage::InternalPixelType;
50 
51  using ImageDimensionType = typename TImage::ImageDimensionType;
52  static constexpr ImageDimensionType ImageDimension = TImage::ImageDimension;
53 
58 
59  // Index value to the image buffer, indexing the current pixel.
61 
62  // A reference to the accessor of the image.
64 
65 
66  // Private helper function. Clamps the index value between the interval
67  // [0 .. imageSizeValue>.
68  static IndexValueType
69  GetClampedIndexValue(const IndexValueType indexValue, const ImageSizeValueType imageSizeValue) ITK_NOEXCEPT
70  {
71  return (indexValue <= 0) ? 0
72  : (static_cast<ImageSizeValueType>(indexValue) < imageSizeValue)
73  ? indexValue
74  : static_cast<IndexValueType>(imageSizeValue - 1);
75  }
76 
77  // Private helper function. Calculates and returns the index value of the
78  // current pixel within the image buffer.
79  static IndexValueType
81  const OffsetType & offsetTable,
82  const IndexType & pixelIndex) ITK_NOEXCEPT
83  {
84  IndexValueType result = 0;
85 
86  for (ImageDimensionType i = 0; i < ImageDimension; ++i)
87  {
88  result += GetClampedIndexValue(pixelIndex[i], imageSize[i]) * offsetTable[i];
89  }
90  return result;
91  }
92 
93 public:
94  // Deleted member functions:
98 
99  // Explicitly-defaulted functions:
102  ITK_NOEXCEPT = default;
103 
107  const OffsetType & offsetTable,
108  const NeighborhoodAccessorFunctorType & neighborhoodAccessor,
109  const IndexType & pixelIndex) ITK_NOEXCEPT
110  : m_PixelIndexValue{ CalculatePixelIndexValue(imageSize, offsetTable, pixelIndex) }
111  , m_NeighborhoodAccessor(neighborhoodAccessor)
112  {}
114 
117  PixelType
118  GetPixelValue(const InternalPixelType * const imageBufferPointer) const ITK_NOEXCEPT
119  {
120  return m_NeighborhoodAccessor.Get(imageBufferPointer + m_PixelIndexValue);
121  }
122 
125  void
126  SetPixelValue(InternalPixelType * const imageBufferPointer, const PixelType & pixelValue) const ITK_NOEXCEPT
127  {
128  m_NeighborhoodAccessor.Set(imageBufferPointer + m_PixelIndexValue, pixelValue);
129  }
130 };
132 
133 } // namespace Experimental
134 } // namespace itk
135 
136 #endif
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::NeighborhoodAccessorFunctorType
typename TImage::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:47
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:66
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::CalculatePixelIndexValue
static IndexValueType CalculatePixelIndexValue(const ImageSizeType &imageSize, const OffsetType &offsetTable, const IndexType &pixelIndex) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:80
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:49
itk::Size< ImageDimension >
itkOffset.h
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::GetClampedIndexValue
static IndexValueType GetClampedIndexValue(const IndexValueType indexValue, const ImageSizeValueType imageSizeValue) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:69
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageDimension
static constexpr ImageDimensionType ImageDimension
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:52
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:44
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::GetPixelValue
PixelType GetPixelValue(const InternalPixelType *const imageBufferPointer) const noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:118
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageSizeValueType
SizeValueType ImageSizeValueType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:57
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::~ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
~ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy()=default
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ImageDimensionType
typename TImage::ImageDimensionType ImageDimensionType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:51
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::operator=
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy & operator=(const ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy &)=delete
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::m_NeighborhoodAccessor
const NeighborhoodAccessorFunctorType & m_NeighborhoodAccessor
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:63
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::PixelType
typename TImage::PixelType PixelType
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:48
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::SetPixelValue
void SetPixelValue(InternalPixelType *const imageBufferPointer, const PixelType &pixelValue) const noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:126
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::m_PixelIndexValue
const IndexValueType m_PixelIndexValue
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:60
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy(const ImageSizeType &imageSize, const OffsetType &offsetTable, const NeighborhoodAccessorFunctorType &neighborhoodAccessor, const IndexType &pixelIndex) noexcept
Definition: itkZeroFluxNeumannImageNeighborhoodPixelAccessPolicy.h:106
itkIndex.h
itk::Experimental::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy::ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy
ZeroFluxNeumannImageNeighborhoodPixelAccessPolicy()=delete
itk::Offset< ImageDimension >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itkSize.h