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();
82#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
84 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits<type> \
87 using ComponentType = type; \
89 GetNumberOfComponents() \
94 GetNumberOfComponents(const type) \
99 SetNthComponent(int, type & pixel, const ComponentType & v) \
104 GetNthComponent(int, const type pixel) \
109 GetScalarValue(const type & pixel) \
131#undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
137template <
unsigned int VDimension>
164#define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
165 template <typename TComponentType, unsigned int VDimension> \
166 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits<type<TComponentType, VDimension>> \
169 using TargetType = type<TComponentType, VDimension>; \
170 using ComponentType = TComponentType; \
171 static unsigned int \
172 GetNumberOfComponents() \
176 static unsigned int \
177 GetNumberOfComponents(const TargetType) \
182 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
186 static ComponentType \
187 GetNthComponent(int i, const TargetType pixel) \
191 static ComponentType \
192 GetScalarValue(const TargetType & pixel) \
211template <
typename VComponent>
240 return pixel.GetNorm();
248template <
typename VComponent>
267 const unsigned int row = i / pixel.
Cols();
268 const unsigned int col = i % pixel.
Cols();
274 const unsigned int row = i / pixel.
Cols();
275 const unsigned int col = i % pixel.
Cols();
276 return pixel(row, col);
295template <
typename VComponent,
unsigned int VRows,
unsigned int VCols>
304 return VRows * VCols;
309 const unsigned int row = i / VCols;
310 const unsigned int col = i % VCols;
316 const unsigned int row = i / VCols;
317 const unsigned int col = i % VCols;
318 return pixel[row][col];
331template <
typename TComponent>
357 return std::norm(pixel);
A templated class holding a n-Dimensional covariant vector.
Matrix< VComponent, VRows, VCols > TargetType
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()
Offset< VDimension > TargetType
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static ComponentType GetScalarValue(const TargetType &pixel)
static ComponentType GetNthComponent(int i, const TargetType &pixel)
VariableLengthVector< VComponent > TargetType
static unsigned int GetNumberOfComponents(const TargetType pixel)
static unsigned int GetNumberOfComponents()
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
VariableSizeMatrix< VComponent > TargetType
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 unsigned int GetNumberOfComponents(const PixelType pixel)
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
typename PixelType::ComponentType ComponentType
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.
#define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type)
#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
itk::OffsetValueType OffsetValueType