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) \
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 DefaultConvertPixelTraits< type< TComponentType, VDimension > > \
147 typedef type< TComponentType, VDimension > TargetType; \
148 typedef TComponentType ComponentType; \
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 >
308 pixel = TargetType( v, pixel.imag() );
312 pixel = TargetType(pixel.real(), v);
317 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()