18#ifndef itkDefaultConvertPixelTraits_h
19#define itkDefaultConvertPixelTraits_h
40template <
typename PixelType>
51 return PixelType::GetNumberOfComponents();
57 return PixelType::GetNumberOfComponents();
64 return pixel.GetNthComponent(c);
71 pixel.SetNthComponent(c, v);
78 return pixel.GetScalarValue();
83#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
85 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits<type> \
88 using ComponentType = type; \
90 GetNumberOfComponents() \
95 GetNumberOfComponents(const type) \
100 SetNthComponent(int, type & pixel, const ComponentType & v) \
105 GetNthComponent(int, const type pixel) \
110 GetScalarValue(const type & pixel) \
132#undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
138template <
unsigned int VDimension>
165#define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
166 template <typename TComponentType, unsigned int VDimension> \
167 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits<type<TComponentType, VDimension>> \
170 using TargetType = type<TComponentType, VDimension>; \
171 using ComponentType = TComponentType; \
172 static unsigned int \
173 GetNumberOfComponents() \
177 static unsigned int \
178 GetNumberOfComponents(const TargetType) \
183 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
187 static ComponentType \
188 GetNthComponent(int i, const TargetType pixel) \
192 static ComponentType \
193 GetScalarValue(const TargetType & pixel) \
212template <
typename VComponent>
241 return pixel.GetNorm();
249template <
typename VComponent>
268 const unsigned int row = i / pixel.
Cols();
269 const unsigned int col = i % pixel.
Cols();
275 const unsigned int row = i / pixel.
Cols();
276 const unsigned int col = i % pixel.
Cols();
277 return pixel(row, col);
296template <
typename VComponent,
unsigned int VRows,
unsigned int VCols>
305 return VRows * VCols;
310 const unsigned int row = i / VCols;
311 const unsigned int col = i % VCols;
317 const unsigned int row = i / VCols;
318 const unsigned int col = i % VCols;
319 return pixel[row][col];
332template <
typename TComponent>
358 return std::norm(pixel);
A templated class holding a n-Dimensional covariant vector.
static ComponentType GetScalarValue(const TargetType &pixel)
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static ComponentType GetNthComponent(int i, const TargetType &pixel)
static unsigned int GetNumberOfComponents()
static ComponentType GetScalarValue(const TargetType &pixel)
typename TargetType::OffsetValueType ComponentType
static unsigned int GetNumberOfComponents()
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static ComponentType GetScalarValue(const TargetType &pixel)
static ComponentType GetNthComponent(int i, const TargetType &pixel)
static unsigned int GetNumberOfComponents(const TargetType pixel)
static unsigned int GetNumberOfComponents()
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static ComponentType GetScalarValue(const TargetType &)
static ComponentType GetNthComponent(int i, const TargetType &pixel)
static unsigned int GetNumberOfComponents(const TargetType pixel)
static unsigned int GetNumberOfComponents()
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
std::complex< TComponent > TargetType
static ComponentType GetScalarValue(const TargetType &pixel)
static unsigned int GetNumberOfComponents()
Traits class used to by ConvertPixels to convert blocks of pixels.
static ComponentType GetNthComponent(int c, const PixelType &pixel)
static ComponentType GetScalarValue(const PixelType &pixel)
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
typename PixelType::ComponentType ComponentType
static unsigned int GetNumberOfComponents(const PixelType)
static unsigned int GetNumberOfComponents()
Simulate a standard C array with copy semantics.
A templated class holding a M x N size Matrix.
A templated class holding a geometric point in n-Dimensional space.
A templated class holding a M x N size Matrix.
unsigned int Cols() const
unsigned int Rows() const
A templated class holding a n-Dimensional vector.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char)
ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector)
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.