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);