00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSpatialObjectToImageStatisticsCalculator_h
00018 #define __itkSpatialObjectToImageStatisticsCalculator_h
00019
00020 #include "itkObject.h"
00021 #include "itkObjectFactory.h"
00022 #include "itkFloodFilledSpatialFunctionConditionalConstIterator.h"
00023 #include "itkMatrix.h"
00024 #include "itkNumericTraits.h"
00025
00026 namespace itk
00027 {
00028
00033 template <class TInputImage, class TInputSpatialObject, unsigned int TSampleDimension=1>
00034 class ITK_EXPORT SpatialObjectToImageStatisticsCalculator : public Object
00035 {
00036 public:
00037
00039 typedef SpatialObjectToImageStatisticsCalculator Self;
00040 typedef Object Superclass;
00041 typedef SmartPointer<Self> Pointer;
00042 typedef SmartPointer<const Self> ConstPointer;
00043
00045 itkNewMacro(Self);
00046
00048 itkTypeMacro(SpatialObjectToImageStatisticsCalculator, Object);
00049
00051 typedef TInputImage ImageType;
00052 typedef typename TInputImage::Pointer ImagePointer;
00053 typedef typename TInputImage::ConstPointer ImageConstPointer;
00054 typedef typename TInputImage::PixelType PixelType;
00055 typedef typename TInputImage::IndexType IndexType;
00056 typedef typename NumericTraits< PixelType >::AccumulateType AccumulateType;
00057
00058 itkStaticConstMacro(ImageDimension, unsigned int,
00059 ImageType::ImageDimension);
00060
00061 itkStaticConstMacro(SampleDimension, unsigned int,
00062 TSampleDimension);
00063
00064 itkStaticConstMacro(ObjectDimension, unsigned int,
00065 TInputSpatialObject::ObjectDimension);
00066
00067
00069 typedef TInputSpatialObject SpatialObjectType;
00070 typedef typename SpatialObjectType::Pointer SpatialObjectPointer;
00071 typedef typename SpatialObjectType::ConstPointer SpatialObjectConstPointer;
00072
00074 typedef itk::FloodFilledSpatialFunctionConditionalConstIterator<ImageType,
00075 SpatialObjectType> IteratorType;
00076
00078 typedef Vector< double, TSampleDimension> VectorType;
00079 typedef Matrix< double, TSampleDimension, TSampleDimension > MatrixType ;
00080
00082 itkSetMacro(SampleDirection,unsigned int);
00083 itkGetMacro(SampleDirection,unsigned int);
00085
00087 itkSetConstObjectMacro(Image,ImageType);
00088
00090 itkSetObjectMacro(SpatialObject,SpatialObjectType);
00091
00093 const VectorType & GetMean() const {return m_Mean;}
00094
00096 const MatrixType & GetCovarianceMatrix() const {return m_CovarianceMatrix;}
00097
00099 AccumulateType GetSum() const {return m_Sum;}
00100
00102 itkGetConstMacro(NumberOfPixels,unsigned long);
00103
00105 void Update(void);
00106
00107 protected:
00108 SpatialObjectToImageStatisticsCalculator();
00109 virtual ~SpatialObjectToImageStatisticsCalculator() {};
00110 void PrintSelf(std::ostream& os, Indent indent) const;
00111
00112 private:
00113 SpatialObjectToImageStatisticsCalculator(const Self&);
00114 void operator=(const Self&);
00115
00116 ImageConstPointer m_Image;
00117 SpatialObjectPointer m_SpatialObject;
00118 VectorType m_Mean;
00119 AccumulateType m_Sum;
00120 unsigned long m_NumberOfPixels;
00121 MatrixType m_CovarianceMatrix;
00122 unsigned int m_SampleDirection;
00123 unsigned long m_InternalImageTime;
00124 unsigned long m_InternalSpatialObjectTime;
00125 TimeStamp m_ModifiedTime;
00126 };
00127
00128 }
00129
00130
00131 #ifndef ITK_MANUAL_INSTANTIATION
00132 #include "itkSpatialObjectToImageStatisticsCalculator.txx"
00133 #endif
00134
00135 #endif
00136