00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkJointDomainImageToListAdaptor_h
00018 #define __itkJointDomainImageToListAdaptor_h
00019
00020 #include "itkMacro.h"
00021 #include "itkFixedArray.h"
00022 #include "itkPoint.h"
00023 #include "itkPixelTraits.h"
00024 #include "itkImageToListAdaptor.h"
00025 #include "itkImageRegionConstIteratorWithIndex.h"
00026 #include "itkEuclideanDistance.h"
00027 #include "itkListSample.h"
00028
00029 namespace itk{
00030 namespace Statistics{
00031
00039 template< class TImage >
00040 struct ImageJointDomainTraits
00041 {
00042 typedef ImageJointDomainTraits Self ;
00043 typedef PixelTraits< typename TImage::PixelType > PixelTraitsType ;
00044 typedef typename PixelTraitsType::ValueType RangeDomainMeasurementType ;
00045 typedef typename TImage::IndexType::IndexValueType IndexValueType ;
00046 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension) ;
00047 itkStaticConstMacro(Dimension,
00048 unsigned int,
00049 TImage::ImageDimension +
00050 PixelTraitsType::Dimension ) ;
00051 typedef float CoordinateRepType ;
00052 typedef Point< CoordinateRepType, itkGetStaticConstMacro(ImageDimension) > PointType ;
00053 typedef JoinTraits< RangeDomainMeasurementType, CoordinateRepType >
00054 JoinTraitsType ;
00055 typedef typename JoinTraitsType::ValueType MeasurementType ;
00056 typedef FixedArray< MeasurementType, itkGetStaticConstMacro(Dimension) >
00057 MeasurementVectorType ;
00058 } ;
00059
00089 template < class TImage >
00090 class ITK_EXPORT JointDomainImageToListAdaptor
00091 : public ImageToListAdaptor<
00092 TImage,
00093 typename ImageJointDomainTraits< TImage >::MeasurementVectorType >
00094 {
00095 public:
00096 typedef ImageJointDomainTraits< TImage > ImageJointDomainTraitsType ;
00097 typedef typename ImageJointDomainTraitsType::MeasurementVectorType
00098 MeasurementVectorType ;
00099 typedef typename ImageJointDomainTraitsType::MeasurementType
00100 MeasurementType ;
00101 typedef typename ImageJointDomainTraitsType::RangeDomainMeasurementType
00102 RangeDomainMeasurementType ;
00103 typedef typename ImageJointDomainTraitsType::PointType PointType ;
00104 typedef typename ImageJointDomainTraitsType::CoordinateRepType
00105 CoordinateRepType ;
00107 typedef JointDomainImageToListAdaptor Self;
00108 typedef ImageToListAdaptor< TImage, MeasurementVectorType >
00109 Superclass;
00110 typedef SmartPointer< Self > Pointer;
00111 typedef SmartPointer<const Self> ConstPointer;
00112
00114 itkTypeMacro(JointDomainImageToListAdaptor, ImageToListAdaptor) ;
00115
00117 itkNewMacro(Self) ;
00118
00120 itkStaticConstMacro(MeasurementVectorSize,
00121 unsigned int,
00122 ImageJointDomainTraitsType::Dimension) ;
00123
00124 typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00125
00126 virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType s )
00127 {
00128
00129
00130 if( s != MeasurementVectorSize )
00131 {
00132 itkExceptionMacro( << "Cannot set measurement vector size of "
00133 << " JointDomainImageToListAdaptor to " << s );
00134 }
00135 }
00136
00137 MeasurementVectorSizeType GetMeasurementVectorSize() const
00138 {
00139 return MeasurementVectorSize;
00140 }
00141
00144 typedef typename Superclass::FrequencyType FrequencyType ;
00145 typedef typename Superclass::InstanceIdentifier InstanceIdentifier ;
00146
00147 typedef typename TImage::IndexType ImageIndexType ;
00148 typedef typename TImage::IndexType::IndexValueType ImageIndexValueType ;
00149 typedef typename TImage::SizeType ImageSizeType ;
00150 typedef typename TImage::RegionType ImageRegionType ;
00151 typedef ImageRegionConstIteratorWithIndex< TImage > ImageIteratorType ;
00152
00153 typedef MeasurementVectorType ValueType ;
00154
00155 itkStaticConstMacro(RangeDomainDimension,
00156 unsigned int,
00157 itk::PixelTraits<
00158 typename TImage::PixelType >::Dimension) ;
00159
00160 typedef FixedArray< RangeDomainMeasurementType,
00161 itkGetStaticConstMacro( RangeDomainDimension ) >
00162 RangeDomainMeasurementVectorType ;
00163
00164 typedef std::vector< InstanceIdentifier > InstanceIdentifierVectorType ;
00165
00166 typedef FixedArray< float, itkGetStaticConstMacro(MeasurementVectorSize) >
00167 NormalizationFactorsType ;
00168
00170 void SetNormalizationFactors(NormalizationFactorsType& factors) ;
00171
00174 inline const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const;
00175
00178 inline void ComputeRegion(const MeasurementVectorType& mv,
00179 const double radius,
00180 ImageRegionType& region) const;
00181
00185 inline void Search(const MeasurementVectorType& mv,
00186 const double radius,
00187 InstanceIdentifierVectorType& result) const;
00188
00189 protected:
00190 JointDomainImageToListAdaptor() ;
00191 virtual ~JointDomainImageToListAdaptor() {}
00192 void PrintSelf(std::ostream& os, Indent indent) const;
00193
00194 private:
00195 JointDomainImageToListAdaptor(const Self&) ;
00196 void operator=(const Self&) ;
00197
00198 NormalizationFactorsType m_NormalizationFactors ;
00199
00200 mutable MeasurementVectorType m_TempVector ;
00201 mutable PointType m_TempPoint ;
00202 mutable ImageIndexType m_TempIndex ;
00203 mutable RangeDomainMeasurementVectorType m_TempRangeVector ;
00204 } ;
00205
00206 }
00207 }
00208
00209 #ifndef ITK_MANUAL_INSTANTIATION
00210 #include "itkJointDomainImageToListAdaptor.txx"
00211 #endif
00212
00213 #endif