ITK  6.0.0
Insight Toolkit
itkVectorImageNeighborhoodAccessorFunctor.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 * https://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#ifndef itkVectorImageNeighborhoodAccessorFunctor_h
19#define itkVectorImageNeighborhoodAccessorFunctor_h
20
23#include "itkImageBase.h"
24
25namespace itk
26{
40template <typename TImage>
42{
43public:
44 using ImageType = TImage;
45 using PixelType = typename ImageType::PixelType;
46 using InternalPixelType = typename ImageType::InternalPixelType;
47 using VectorLengthType = unsigned int;
48 using OffsetType = typename ImageType::OffsetType;
49
51
52 template <typename TOutput = ImageType>
54
56 : m_VectorLength(length)
57 , m_OffsetMultiplier(length - 1)
58 {}
60
74 inline void
76 {
77 this->m_Begin = const_cast<InternalPixelType *>(begin);
78 }
88 inline PixelType
89 Get(const InternalPixelType * pixelPointer) const
90 {
91 return PixelType(pixelPointer + (pixelPointer - m_Begin) * m_OffsetMultiplier, m_VectorLength);
92 }
93
95 inline void
96 Set(InternalPixelType * const pixelPointer, const PixelType & p) const
97 {
98 InternalPixelType * const truePixelPointer = pixelPointer + (pixelPointer - m_Begin) * m_OffsetMultiplier;
99
100 for (VectorLengthType i = 0; i < m_VectorLength; ++i)
101 {
102 truePixelPointer[i] = p[i];
103 }
104 }
105
106
107 template <typename TOutput>
109 BoundaryCondition(const OffsetType & point_index,
110 const OffsetType & boundary_offset,
111 const NeighborhoodType * data,
112 const ImageBoundaryConditionType<TOutput> * boundaryCondition) const
113 {
114 return boundaryCondition->operator()(point_index, boundary_offset, data, *this);
115 }
116
119 void
121 {
122 m_VectorLength = length;
123 m_OffsetMultiplier = length - 1;
124 }
125
130 {
131 return m_VectorLength;
132 }
133
134private:
136 VectorLengthType m_OffsetMultiplier{ 0 }; // m_OffsetMultiplier = m_VectorLength-1
137 // (precomputed for speedup).
138 InternalPixelType * m_Begin{ nullptr }; // Begin of the buffer.
139};
140} // end namespace itk
141#endif
A virtual base object that defines an interface to a class of boundary condition objects for use by n...
typename TOutputImage::PixelType OutputPixelType
A light-weight container object for storing an N-dimensional neighborhood of values.
Provides accessor interfaces to Access pixels and is meant to be used on pointers to pixels held by t...
void Set(InternalPixelType *const pixelPointer, const PixelType &p) const
ImageBoundaryConditionType< TOutput >::OutputPixelType BoundaryCondition(const OffsetType &point_index, const OffsetType &boundary_offset, const NeighborhoodType *data, const ImageBoundaryConditionType< TOutput > *boundaryCondition) const
PixelType Get(const InternalPixelType *pixelPointer) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....