00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageToListGenerator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/04/25 22:25:16 $ 00007 Version: $Revision: 1.3 $ 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 __itkImageToListGenerator_h 00018 #define __itkImageToListGenerator_h 00019 00020 #include "itkListSample.h" 00021 #include "itkPixelTraits.h" 00022 #include "itkProcessObject.h" 00023 #include "itkDataObject.h" 00024 #include "itkDataObjectDecorator.h" 00025 #include "itkFixedArray.h" 00026 00027 namespace itk { 00028 namespace Statistics { 00029 00053 template < class TImage, class TMaskImage = TImage > 00054 class ITK_EXPORT ImageToListGenerator : 00055 public ProcessObject 00056 { 00057 public: 00059 typedef ImageToListGenerator Self; 00060 typedef ProcessObject Superclass; 00061 typedef SmartPointer< Self > Pointer; 00062 typedef SmartPointer<const Self> ConstPointer; 00063 00065 itkTypeMacro(ImageToListGenerator, ProcessObject); 00066 00068 itkNewMacro(Self); 00069 00071 typedef TImage ImageType; 00072 typedef typename ImageType::Pointer ImagePointer; 00073 typedef typename ImageType::ConstPointer ImageConstPointer; 00074 typedef typename ImageType::PixelType PixelType; 00075 typedef FixedArray< PixelType, 1 > MeasurementVectorType; 00076 00078 typedef TMaskImage MaskImageType; 00079 typedef typename MaskImageType::Pointer MaskImagePointer; 00080 typedef typename MaskImageType::ConstPointer MaskImageConstPointer; 00081 typedef typename MaskImageType::PixelType MaskPixelType; 00082 00084 typedef ListSample< MeasurementVectorType > ListSampleType; 00085 00088 typedef PixelTraits< typename ImageType::PixelType > PixelTraitsType; 00089 typedef typename ListSampleType::MeasurementVectorSizeType 00090 MeasurementVectorSizeType; 00091 00092 typedef DataObject::Pointer DataObjectPointer; 00093 00096 typedef DataObjectDecorator< ListSampleType > ListSampleOutputType; 00097 00099 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00100 PixelTraitsType::Dimension); 00101 00103 virtual DataObjectPointer MakeOutput(unsigned int idx); 00104 00105 virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType s ) 00106 { 00107 // Measurement vector size for this class is fixed as the pixel's 00108 // dimension. This method should throw an exception if the user tries to 00109 // set the dimension to a different value. 00110 if( s != MeasurementVectorSize ) 00111 { 00112 itkExceptionMacro( 00113 << "Measurement vector size for the image adaptor obtained" 00114 << " from the pixel dimension is: " 00115 << MeasurementVectorSize << " but you " 00116 << "are setting it to " << s); 00117 } 00118 } 00119 00120 unsigned int GetMeasurementVectorSize() const 00121 { 00122 return MeasurementVectorSize; 00123 } 00124 00126 void SetInput( const ImageType* image ); 00127 const ImageType* GetInput() const; 00129 00131 void SetMaskImage( const MaskImageType* image ); 00132 const MaskImageType* GetMaskImage() const; 00134 00138 const ListSampleType * GetListSample() const; 00139 00144 itkSetMacro( MaskValue, MaskPixelType ); 00145 itkGetMacro( MaskValue, MaskPixelType ); 00147 00149 virtual void GenerateData(); 00150 00153 virtual void GenerateInputRequestedRegion() 00154 throw(InvalidRequestedRegionError); 00155 00156 virtual void GenerateOutputInformation(); 00157 00158 protected: 00159 ImageToListGenerator(); 00160 virtual ~ImageToListGenerator() {} 00161 void PrintSelf(std::ostream& os, Indent indent) const; 00162 00163 private: 00164 ImageToListGenerator(const Self&); //purposely not implemented 00165 void operator=(const Self&); //purposely not implemented 00166 00167 MaskPixelType m_MaskValue; 00168 00169 }; // end of class ImageToListGenerator 00170 00171 } // end of namespace Statistics 00172 } // end of namespace itk 00173 00174 #ifndef ITK_MANUAL_INSTANTIATION 00175 #include "itkImageToListGenerator.txx" 00176 #endif 00177 00178 #endif 00179