00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkScalarImageToListAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-08-19 22:27:57 $ 00007 Version: $Revision: 1.7 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkScalarImageToListAdaptor_h 00018 #define __itkScalarImageToListAdaptor_h 00019 00020 #include <typeinfo> 00021 00022 #include "itkImage.h" 00023 #include "itkPixelTraits.h" 00024 #include "itkImageToListAdaptor.h" 00025 #include "itkSmartPointer.h" 00026 #include "itkImageRegionIterator.h" 00027 #include "itkFixedArray.h" 00028 #include "itkMacro.h" 00029 00030 namespace itk{ 00031 namespace Statistics{ 00032 00062 template < class TImage > 00063 class ITK_EXPORT ScalarImageToListAdaptor 00064 : public ImageToListAdaptor< 00065 TImage, 00066 FixedArray< typename TImage::PixelType, 1 > > 00067 { 00068 public: 00069 typedef FixedArray< typename TImage::PixelType, 1 > MeasurementVectorType; 00070 00072 typedef ScalarImageToListAdaptor Self; 00073 typedef ImageToListAdaptor< TImage, MeasurementVectorType > Superclass; 00074 typedef SmartPointer< Self > Pointer; 00075 typedef SmartPointer<const Self> ConstPointer; 00076 00078 itkTypeMacro(ScalarImageToListAdaptor, ListSampleBase); 00079 00081 itkNewMacro(Self); 00082 00084 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 1); 00085 00086 00089 typedef typename Superclass::FrequencyType FrequencyType; 00090 typedef typename Superclass::MeasurementType MeasurementType; 00091 typedef typename Superclass::InstanceIdentifier InstanceIdentifier; 00092 typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType; 00093 typedef MeasurementVectorType ValueType; 00094 00095 virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType s ) 00096 { 00097 // Measurement vector size for this class is fixed as the pixel's 00098 // dimension. This method should have no effect 00099 if( s!=1 ) 00100 { 00101 itkExceptionMacro( << "Cannot set measurement vector size of " 00102 << " ScalarImageToListAdaptor to " << s ); 00103 } 00104 } 00105 00107 MeasurementVectorSizeType GetMeasurementVectorSize() const 00108 { 00109 return MeasurementVectorSize; 00110 } 00111 00112 const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const; 00113 00114 protected: 00115 ScalarImageToListAdaptor() 00116 { 00117 Superclass::SetMeasurementVectorSize( MeasurementVectorSize); 00118 } 00119 00120 virtual ~ScalarImageToListAdaptor() {} 00121 void PrintSelf(std::ostream& os, Indent indent) const; 00122 00123 private: 00124 ScalarImageToListAdaptor(const Self&); //purposely not implemented 00125 void operator=(const Self&); //purposely not implemented 00126 mutable MeasurementVectorType m_TempVector; 00127 }; // end of class ScalarImageToListAdaptor 00128 00129 } // end of namespace Statistics 00130 } // end of namespace itk 00131 00132 #ifndef ITK_MANUAL_INSTANTIATION 00133 #include "itkScalarImageToListAdaptor.txx" 00134 #endif 00135 00136 #endif 00137