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 DefaultConvertPixelTraits< type > \
73 typedef type ComponentType; \
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) \
111 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
117 template<
unsigned int VDimension>
141 #define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
142 template<typename TComponentType, unsigned VDimension > \
143 class DefaultConvertPixelTraits< type< TComponentType, VDimension > > \
146 typedef type< TComponentType, VDimension > TargetType; \
147 typedef TComponentType ComponentType; \
148 static unsigned int GetNumberOfComponents() \
152 static unsigned int GetNumberOfComponents( const TargetType ) \
156 static void SetNthComponent(int i, TargetType & pixel, \
157 const ComponentType &v) \
161 static ComponentType GetNthComponent(int i, const TargetType pixel) \
165 static ComponentType GetScalarValue(const TargetType &pixel) \
184 template<
typename VComponent>
217 template<
typename VComponent>
234 const unsigned int row = i / pixel.
Cols();
235 const unsigned int col = i % pixel.
Cols();
240 const unsigned int row = i / pixel.
Cols();
241 const unsigned int col = i % pixel.
Cols();
242 return pixel(row,col);
260 template<
typename VComponent,
unsigned VRows,
unsigned VCols >
268 return VRows * VCols;
273 const unsigned int row = i / VCols;
274 const unsigned int col = i % VCols;
279 const unsigned int row = i / VCols;
280 const unsigned int col = i % VCols;
281 return pixel[row][col];
293 template<
typename TComponent >
307 pixel = TargetType( v, pixel.imag() );
311 pixel = TargetType(pixel.real(), v);
316 return std::norm(pixel);
VariableSizeMatrix< VComponent > TargetType
A templated class holding a M x N size Matrix.
unsigned int Rows() const
TargetType::OffsetValueType ComponentType
Represent the offset between two n-dimensional indexes in a n-dimensional image.
static ComponentType GetScalarValue(const PixelType &pixel)
static unsigned int GetNumberOfComponents(const PixelType)
unsigned int Size(void) const
static unsigned int GetNumberOfComponents(const TargetType pixel)
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.
VariableLengthVector< VComponent > TargetType
PixelType::ComponentType ComponentType
static ComponentType GetNthComponent(int i, const TargetType &pixel)
Offset< VDimension > TargetType
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)
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
Matrix< VComponent, VRows, VCols > TargetType
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
static unsigned int GetNumberOfComponents()
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)
static ComponentType GetScalarValue(const TargetType &pixel)
itk::OffsetValueType OffsetValueType
static void SetNthComponent(int i, TargetType &pixel, const ComponentType &v)
typedef::std::complex< TComponent > TargetType
static unsigned int GetNumberOfComponents()
static unsigned int GetNumberOfComponents()