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) \
109 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
115 template<
unsigned int VDimension>
139 #define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
140 template<typename TComponentType, unsigned VDimension > \
141 class DefaultConvertPixelTraits< type< TComponentType, VDimension > > \
144 typedef type< TComponentType, VDimension > TargetType; \
145 typedef TComponentType ComponentType; \
146 static unsigned int GetNumberOfComponents() \
150 static unsigned int GetNumberOfComponents( const TargetType ) \
154 static void SetNthComponent(int i, TargetType & pixel, \
155 const ComponentType &v) \
159 static ComponentType GetNthComponent(int i, const TargetType pixel) \
163 static ComponentType GetScalarValue(const TargetType &pixel) \
182 template<
typename VComponent>
215 template<
typename VComponent>
232 const unsigned int row = i / pixel.
Cols();
233 const unsigned int col = i % pixel.
Cols();
238 const unsigned int row = i / pixel.
Cols();
239 const unsigned int col = i % pixel.
Cols();
240 return pixel(row,col);
258 template<
typename VComponent,
unsigned VRows,
unsigned VCols >
266 return VRows * VCols;
271 const unsigned int row = i / VCols;
272 const unsigned int col = i % VCols;
277 const unsigned int row = i / VCols;
278 const unsigned int col = i % VCols;
279 return pixel[row][col];
291 template<
typename TComponent >
305 pixel = TargetType( v, pixel.imag() );
309 pixel = TargetType(pixel.real(), v);
314 return std::norm(pixel);