00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorImageToImageAdaptor_h
00018 #define __itkVectorImageToImageAdaptor_h
00019
00020 #include "itkImageAdaptor.h"
00021 #include "itkVectorImage.h"
00022
00023 namespace itk
00024 {
00025 namespace Accessor
00026 {
00027
00042 template <class TType >
00043 class ITK_EXPORT VectorImageToImagePixelAccessor
00044 {
00045 public:
00046
00047 typedef unsigned int VectorLengthType;
00048
00051 typedef TType ExternalType;
00052
00055 typedef VariableLengthVector< TType > InternalType;
00056
00058 typedef TType PixelType;
00059
00060 inline void Set(InternalType output, const ExternalType & input) const
00061 {
00062 output[m_ComponentIdx] = input;
00063 }
00064
00065 inline ExternalType Get( const InternalType & input ) const
00066 {
00067 ExternalType output;
00068 output = input[m_ComponentIdx];
00069 return output;
00070 }
00071
00072 void SetExtractComponentIdx( VectorLengthType idx )
00073 {
00074 m_ComponentIdx = idx;
00075 }
00076 VectorLengthType GetExtractComponentIdx() const
00077 {
00078 return m_ComponentIdx;
00079 }
00080
00081 VectorImageToImagePixelAccessor() : m_ComponentIdx( 0 ) {};
00082 virtual ~VectorImageToImagePixelAccessor() {};
00083
00084 private:
00085 VectorLengthType m_ComponentIdx;
00086 };
00087
00088 }
00089
00090
00091
00109 template<class TPixelType, unsigned int Dimension>
00110 class ITK_EXPORT VectorImageToImageAdaptor : public
00111 ImageAdaptor< VectorImage< TPixelType, Dimension >,
00112 Accessor::VectorImageToImagePixelAccessor< TPixelType > >
00113 {
00114 public:
00116 typedef VectorImageToImageAdaptor Self;
00117 typedef VectorImage< TPixelType, Dimension > VectorImageType;
00118 typedef ImageAdaptor< VectorImageType,
00119 Accessor::VectorImageToImagePixelAccessor< TPixelType > > Superclass;
00120 typedef SmartPointer<Self> Pointer;
00121 typedef SmartPointer<const Self> ConstPointer;
00122
00124 itkNewMacro(Self);
00125
00127 itkTypeMacro( VectorImageToImageAdaptor, ImageAdaptor );
00128
00131 typedef typename Superclass::PixelContainer PixelContainer;
00132 typedef typename Superclass::PixelContainerPointer PixelContainerPointer;
00133 typedef typename Superclass::PixelContainerConstPointer PixelContainerConstPointer;
00134 typedef typename Superclass::IOPixelType IOPixelType;
00135
00137 typedef typename VectorImageType::VectorLengthType VectorLengthType;
00138
00139
00140 void SetExtractComponentIndex( VectorLengthType componentIdx )
00141 {
00142 this->GetPixelAccessor().SetExtractComponentIdx( componentIdx );
00143 }
00144
00145
00146 VectorLengthType GetExtractComponentIndex() const
00147 {
00148 return this->GetPixelAccessor().GetExtractComponentIdx();
00149 }
00150
00151 protected:
00152 VectorImageToImageAdaptor() {}
00153 virtual ~VectorImageToImageAdaptor() {}
00154
00155 private:
00156 VectorImageToImageAdaptor(const Self&);
00157 void operator=(const Self&);
00158
00159 };
00160
00161
00162 }
00163
00164 #endif
00165