18 #ifndef __itkDefaultConvertPixelTraits_h
19 #define __itkDefaultConvertPixelTraits_h
39 template<
typename PixelType >
55 {
return pixel.GetNthComponent(c); }
59 { pixel.SetNthComponent(c, v); }
63 {
return pixel.GetScalarValue(); }
67 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
69 class DefaultConvertPixelTraits< type > \
72 typedef type ComponentType; \
73 static unsigned int GetNumberOfComponents() \
77 static unsigned int GetNumberOfComponents(const type) \
81 static void SetNthComponent(int, type & pixel, const ComponentType &v) \
85 static type GetNthComponent(int, const type pixel) \
89 static type GetScalarValue(const type &pixel) \
108 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
114 template<
unsigned int VDimension>
138 #define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \
139 template<typename TComponentType, unsigned VDimension > \
140 class DefaultConvertPixelTraits< type< TComponentType, VDimension > > \
143 typedef type< TComponentType, VDimension > TargetType; \
144 typedef TComponentType ComponentType; \
145 static unsigned int GetNumberOfComponents() \
149 static unsigned int GetNumberOfComponents( const TargetType ) \
153 static void SetNthComponent(int i, TargetType & pixel, \
154 const ComponentType &v) \
158 static ComponentType GetNthComponent(int i, const TargetType pixel) \
162 static ComponentType GetScalarValue(const TargetType &pixel) \
181 template<
typename VComponent>
220 template<
typename VComponent,
unsigned VRows,
unsigned VCols >
228 return VRows * VCols;
233 const unsigned int row = i / VCols;
234 const unsigned int col = i % VCols;
247 template<
typename TComponent >
261 pixel = TargetType( v, pixel.imag() );
265 pixel = TargetType(pixel.real(), v);
270 return std::norm(pixel);