18 #ifndef itkDefaultConvertPixelTraits_h
19 #define itkDefaultConvertPixelTraits_h
40 template<
typename PixelType >
49 {
return PixelType::GetNumberOfComponents(); }
52 {
return PixelType::GetNumberOfComponents( ); }
56 {
return pixel.GetNthComponent(c); }
60 { pixel.SetNthComponent(c, v); }
64 {
return pixel.GetScalarValue(); }
68 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
70 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits< type > \
73 using ComponentType = type; \
74 static unsigned int GetNumberOfComponents() \
78 static unsigned int GetNumberOfComponents(const type) \
82 static void SetNthComponent(int, type & pixel, const ComponentType &v) \
86 static type GetNthComponent(int, const type pixel) \
90 static type GetScalarValue(const type &pixel) \
112 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
118 template<
unsigned int VDimension>
142 #define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
143 template<typename TComponentType, unsigned VDimension > \
144 class ITK_TEMPLATE_EXPORT DefaultConvertPixelTraits< type< TComponentType, VDimension > > \
147 using TargetType = type< TComponentType, VDimension >; \
148 using ComponentType = TComponentType; \
149 static unsigned int GetNumberOfComponents() \
153 static unsigned int GetNumberOfComponents( const TargetType ) \
157 static void SetNthComponent(int i, TargetType & pixel, \
158 const ComponentType &v) \
162 static ComponentType GetNthComponent(int i, const TargetType pixel) \
166 static ComponentType GetScalarValue(const TargetType &pixel) \
185 template<
typename VComponent>
218 template<
typename VComponent>
235 const unsigned int row = i / pixel.
Cols();
236 const unsigned int col = i % pixel.
Cols();
241 const unsigned int row = i / pixel.
Cols();
242 const unsigned int col = i % pixel.
Cols();
243 return pixel(row,col);
261 template<
typename VComponent,
unsigned VRows,
unsigned VCols >
269 return VRows * VCols;
274 const unsigned int row = i / VCols;
275 const unsigned int col = i % VCols;
280 const unsigned int row = i / VCols;
281 const unsigned int col = i % VCols;
282 return pixel[row][col];
294 template<
typename TComponent >
317 return std::norm(pixel);
A templated class holding a M x N size Matrix.
unsigned int Rows() const
static ComponentType GetScalarValue(const PixelType &pixel)
static unsigned int GetNumberOfComponents(const PixelType)
static unsigned int GetNumberOfComponents(const TargetType pixel)
typename TargetType::OffsetValueType ComponentType
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static ComponentType GetScalarValue(const TargetType &pixel)
A templated class holding a M x N size Matrix.
Traits class used to by ConvertPixels to convert blocks of pixels.
static ComponentType GetNthComponent(int i, const TargetType &pixel)
RealValueType GetNorm() const
unsigned int Cols() const
static ComponentType GetNthComponent(int c, const PixelType &pixel)
static ComponentType GetScalarValue(const TargetType &pixel)
static unsigned int GetNumberOfComponents()
Represents an array whose length can be defined at run-time.
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector)
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static unsigned int GetNumberOfComponents()
unsigned int Size() const
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 ComponentType GetScalarValue(const TargetType &pixel)
#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type)
static unsigned int GetNumberOfComponents()
static ComponentType GetNthComponent(int i, const TargetType &pixel)
typename PixelType::ComponentType ComponentType
static ComponentType GetScalarValue(const TargetType &pixel)
signed long OffsetValueType
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
::std::complex< TComponent > TargetType
static unsigned int GetNumberOfComponents()
static unsigned int GetNumberOfComponents()