00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __itkKNNGraphAlphaMutualInformationImageToImageMetric_h
00016 #define __itkKNNGraphAlphaMutualInformationImageToImageMetric_h
00017
00019 #include "itkMultiInputImageToImageMetricBase.h"
00020
00022 #include "itkArray.h"
00023 #include "itkListSampleCArray.h"
00024 #include "itkBinaryTreeBase.h"
00025 #include "itkBinaryTreeSearchBase.h"
00026
00028 #include "itkANNkDTree.h"
00029 #include "itkANNbdTree.h"
00030 #include "itkANNBruteForceTree.h"
00031
00033 #include "itkANNStandardTreeSearch.h"
00034 #include "itkANNFixedRadiusTreeSearch.h"
00035 #include "itkANNPriorityTreeSearch.h"
00036
00038 #include "itkArray2D.h"
00039
00040
00041 namespace itk
00042 {
00071 template < class TFixedImage, class TMovingImage>
00072 class KNNGraphAlphaMutualInformationImageToImageMetric :
00073 public MultiInputImageToImageMetricBase< TFixedImage, TMovingImage>
00074 {
00075 public:
00076
00078 typedef KNNGraphAlphaMutualInformationImageToImageMetric Self;
00079 typedef MultiInputImageToImageMetricBase<
00080 TFixedImage, TMovingImage > Superclass;
00081 typedef SmartPointer<Self> Pointer;
00082 typedef SmartPointer<const Self> ConstPointer;
00083
00085 itkNewMacro( Self );
00086
00088 itkTypeMacro( KNNGraphAlphaMutualInformationImageToImageMetric,
00089 MultiInputImageToImageMetricBase );
00090
00092 typedef typename
00093 Superclass::CoordinateRepresentationType CoordinateRepresentationType;
00094 typedef typename Superclass::MovingImageType MovingImageType;
00095 typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
00096 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
00097 typedef typename Superclass::FixedImageType FixedImageType;
00098 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00099 typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
00100 typedef typename Superclass::TransformType TransformType;
00101 typedef typename Superclass::TransformPointer TransformPointer;
00102 typedef typename Superclass::InputPointType InputPointType;
00103 typedef typename Superclass::OutputPointType OutputPointType;
00104 typedef typename Superclass::TransformParametersType TransformParametersType;
00105 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00106 typedef typename Superclass::InterpolatorType InterpolatorType;
00107 typedef typename Superclass::InterpolatorPointer InterpolatorPointer;
00108 typedef typename Superclass::RealType RealType;
00109 typedef typename Superclass::GradientPixelType GradientPixelType;
00110 typedef typename Superclass::GradientImageType GradientImageType;
00111 typedef typename Superclass::GradientImagePointer GradientImagePointer;
00112 typedef typename Superclass::GradientImageFilterType GradientImageFilterType;
00113 typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00114 typedef typename Superclass::FixedImageMaskType FixedImageMaskType;
00115 typedef typename Superclass::FixedImageMaskPointer FixedImageMaskPointer;
00116 typedef typename Superclass::MovingImageMaskType MovingImageMaskType;
00117 typedef typename Superclass::MovingImageMaskPointer MovingImageMaskPointer;
00118 typedef typename Superclass::MeasureType MeasureType;
00119 typedef typename Superclass::DerivativeType DerivativeType;
00120 typedef typename Superclass::ParametersType ParametersType;
00121 typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
00122 typedef typename Superclass::MovingImageRegionType MovingImageRegionType;
00123 typedef typename Superclass::ImageSamplerType ImageSamplerType;
00124 typedef typename Superclass::ImageSamplerPointer ImageSamplerPointer;
00125 typedef typename Superclass::ImageSampleContainerType ImageSampleContainerType;
00126 typedef typename
00127 Superclass::ImageSampleContainerPointer ImageSampleContainerPointer;
00128 typedef typename Superclass::FixedImageLimiterType FixedImageLimiterType;
00129 typedef typename Superclass::MovingImageLimiterType MovingImageLimiterType;
00130 typedef typename
00131 Superclass::FixedImageLimiterOutputType FixedImageLimiterOutputType;
00132 typedef typename
00133 Superclass::MovingImageLimiterOutputType MovingImageLimiterOutputType;
00134 typedef typename Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType;
00135
00137 typedef typename Superclass::FixedImageVectorType FixedImageVectorType;
00138 typedef typename Superclass::FixedImageMaskVectorType FixedImageMaskVectorType;
00139 typedef typename Superclass::FixedImageRegionVectorType FixedImageRegionVectorType;
00140 typedef typename Superclass::MovingImageVectorType MovingImageVectorType;
00141 typedef typename Superclass::MovingImageMaskVectorType MovingImageMaskVectorType;
00142 typedef typename Superclass::InterpolatorVectorType InterpolatorVectorType;
00143 typedef typename Superclass::FixedImageInterpolatorVectorType FixedImageInterpolatorVectorType;
00144
00146 itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
00147 itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
00148
00150 typedef Array< double > MeasurementVectorType;
00151 typedef typename MeasurementVectorType::ValueType MeasurementVectorValueType;
00152 typedef typename Statistics::ListSampleCArray<
00153 MeasurementVectorType, double > ListSampleType;
00154 typedef typename ListSampleType::Pointer ListSamplePointer;
00155
00157 typedef BinaryTreeBase< ListSampleType > BinaryKNNTreeType;
00158 typedef ANNkDTree< ListSampleType > ANNkDTreeType;
00159 typedef ANNbdTree< ListSampleType > ANNbdTreeType;
00160 typedef ANNBruteForceTree< ListSampleType > ANNBruteForceTreeType;
00161
00163 typedef BinaryTreeSearchBase< ListSampleType > BinaryKNNTreeSearchType;
00164 typedef ANNStandardTreeSearch< ListSampleType > ANNStandardTreeSearchType;
00165 typedef ANNFixedRadiusTreeSearch< ListSampleType > ANNFixedRadiusTreeSearchType;
00166 typedef ANNPriorityTreeSearch< ListSampleType > ANNPriorityTreeSearchType;
00167
00168 typedef typename BinaryKNNTreeSearchType::IndexArrayType IndexArrayType;
00169 typedef typename BinaryKNNTreeSearchType::DistanceArrayType DistanceArrayType;
00170
00171 typedef typename DerivativeType::ValueType DerivativeValueType;
00172 typedef typename TransformJacobianType::ValueType TransformJacobianValueType;
00173
00180 void SetANNkDTree( unsigned int bucketSize, std::string splittingRule );
00181
00183 void SetANNkDTree( unsigned int bucketSize, std::string splittingRuleFixed,
00184 std::string splittingRuleMoving, std::string splittingRuleJoint );
00185
00187 void SetANNbdTree( unsigned int bucketSize, std::string splittingRule,
00188 std::string shrinkingRule );
00189
00191 void SetANNbdTree( unsigned int bucketSize, std::string splittingRuleFixed,
00192 std::string splittingRuleMoving, std::string splittingRuleJoint,
00193 std::string shrinkingRuleFixed, std::string shrinkingRuleMoving,
00194 std::string shrinkingRuleJoint );
00195
00197 void SetANNBruteForceTree( void );
00198
00205 void SetANNStandardTreeSearch( unsigned int kNearestNeighbors,
00206 double errorBound );
00207
00209 void SetANNFixedRadiusTreeSearch( unsigned int kNearestNeighbors,
00210 double errorBound, double squaredRadius );
00211
00213 void SetANNPriorityTreeSearch( unsigned int kNearestNeighbors,
00214 double errorBound );
00215
00221 virtual void Initialize( void ) throw ( ExceptionObject );
00222
00224 void GetDerivative( const TransformParametersType & parameters,
00225 DerivativeType & Derivative ) const;
00226
00228 MeasureType GetValue( const TransformParametersType & parameters ) const;
00229
00231 void GetValueAndDerivative( const TransformParametersType & parameters,
00232 MeasureType& Value, DerivativeType& Derivative ) const;
00233
00235 itkSetClampMacro( Alpha, double, 0.0, 1.0 );
00236
00238 itkGetConstReferenceMacro( Alpha, double );
00239
00241 itkSetClampMacro( AvoidDivisionBy, double, 0.0, 1.0 );
00242
00244 itkGetConstReferenceMacro( AvoidDivisionBy, double );
00245
00246 protected:
00247
00249 KNNGraphAlphaMutualInformationImageToImageMetric();
00250
00252 virtual ~KNNGraphAlphaMutualInformationImageToImageMetric() {};
00253
00255 virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00256
00258 typename BinaryKNNTreeType::Pointer m_BinaryKNNTreeFixed;
00259 typename BinaryKNNTreeType::Pointer m_BinaryKNNTreeMoving;
00260 typename BinaryKNNTreeType::Pointer m_BinaryKNNTreeJoint;
00261
00262 typename BinaryKNNTreeSearchType::Pointer m_BinaryKNNTreeSearcherFixed;
00263 typename BinaryKNNTreeSearchType::Pointer m_BinaryKNNTreeSearcherMoving;
00264 typename BinaryKNNTreeSearchType::Pointer m_BinaryKNNTreeSearcherJoint;
00265
00266 double m_Alpha;
00267 double m_AvoidDivisionBy;
00268
00269 private:
00270 KNNGraphAlphaMutualInformationImageToImageMetric(const Self&);
00271 void operator=(const Self&);
00272
00274 typedef typename Superclass::FixedImagePointType FixedImagePointType;
00275 typedef typename Superclass::MovingImagePointType MovingImagePointType;
00276 typedef typename Superclass::MovingImageDerivativeType MovingImageDerivativeType;
00277 typedef typename Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType;
00278 typedef std::vector<TransformJacobianType> TransformJacobianContainerType;
00279
00280 typedef std::vector<NonZeroJacobianIndicesType> TransformJacobianIndicesContainerType;
00281 typedef Array2D<double> SpatialDerivativeType;
00282 typedef std::vector<SpatialDerivativeType> SpatialDerivativeContainerType;
00283
00295 virtual void ComputeListSampleValuesAndDerivativePlusJacobian(
00296 const ListSamplePointer & listSampleFixed,
00297 const ListSamplePointer & listSampleMoving,
00298 const ListSamplePointer & listSampleJoint,
00299 const bool & doDerivative,
00300 TransformJacobianContainerType & jacobians,
00301 TransformJacobianIndicesContainerType & jacobiansIndices,
00302 SpatialDerivativeContainerType & spatialDerivatives ) const;
00303
00308 virtual void EvaluateMovingFeatureImageDerivatives(
00309 const MovingImagePointType & mappedPoint,
00310 SpatialDerivativeType & featureGradients ) const;
00311
00316 virtual void UpdateDerivativeOfGammas(
00317 const SpatialDerivativeType & D1sparse,
00318 const SpatialDerivativeType & D2sparse_M,
00319 const SpatialDerivativeType & D2sparse_J,
00320
00321
00322
00323 const NonZeroJacobianIndicesType & D1indices,
00324 const NonZeroJacobianIndicesType & D2indices_M,
00325 const NonZeroJacobianIndicesType & D2indices_J,
00326 const MeasurementVectorType & diff_M,
00327 const MeasurementVectorType & diff_J,
00328 const MeasureType & distance_M,
00329 const MeasureType & distance_J,
00330 DerivativeType & dGamma_M,
00331 DerivativeType & dGamma_J ) const;
00332
00333 };
00334
00335 }
00336
00337 #ifndef ITK_MANUAL_INSTANTIATION
00338 #include "itkKNNGraphAlphaMutualInformationImageToImageMetric.txx"
00339 #endif
00340
00341 #endif // end #ifndef __itkKNNGraphAlphaMutualInformationImageToImageMetric_h
00342