ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMeanSquaresImageToImageMetric.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMeanSquaresImageToImageMetric_h
00019 #define __itkMeanSquaresImageToImageMetric_h
00020 
00021 #include "itkImageToImageMetric.h"
00022 #include "itkPoint.h"
00023 #include "itkIndex.h"
00024 
00025 
00026 namespace itk
00027 {
00028 
00038 template< class TFixedImage, class TMovingImage >
00039 class ITK_EXPORT MeanSquaresImageToImageMetric:
00040   public ImageToImageMetric< TFixedImage, TMovingImage >
00041 {
00042 public:
00043 
00045   typedef MeanSquaresImageToImageMetric                   Self;
00046   typedef ImageToImageMetric< TFixedImage, TMovingImage > Superclass;
00047   typedef SmartPointer< Self >                            Pointer;
00048   typedef SmartPointer< const Self >                      ConstPointer;
00049 
00051   itkNewMacro(Self);
00052 
00054   itkTypeMacro(MeanSquaresImageToImageMetric, ImageToImageMetric);
00055 
00057   typedef typename Superclass::TransformType                TransformType;
00058   typedef typename Superclass::TransformPointer             TransformPointer;
00059   typedef typename Superclass::TransformJacobianType        TransformJacobianType;
00060   typedef typename Superclass::InterpolatorType             InterpolatorType;
00061   typedef typename Superclass::MeasureType                  MeasureType;
00062   typedef typename Superclass::DerivativeType               DerivativeType;
00063   typedef typename Superclass::ParametersType               ParametersType;
00064   typedef typename Superclass::FixedImageType               FixedImageType;
00065   typedef typename Superclass::MovingImageType              MovingImageType;
00066   typedef typename Superclass::MovingImagePointType         MovingImagePointType;
00067   typedef typename Superclass::FixedImageConstPointer       FixedImageConstPointer;
00068   typedef typename Superclass::MovingImageConstPointer      MovingImageConstPointer;
00069   typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType;
00070   typedef typename Superclass::FixedImageSampleContainer    FixedImageSampleContainer;
00071   typedef typename Superclass::ImageDerivativesType         ImageDerivativesType;
00072   typedef typename Superclass::WeightsValueType             WeightsValueType;
00073   typedef typename Superclass::IndexValueType               IndexValueType;
00074 
00075   // Needed for evaluation of Jacobian.
00076   typedef typename Superclass::FixedImagePointType FixedImagePointType;
00077 
00079   itkStaticConstMacro(MovingImageDimension, unsigned int,
00080                       MovingImageType::ImageDimension);
00081 
00089   virtual void Initialize(void)
00090   throw ( ExceptionObject );
00091 
00093   MeasureType GetValue(const ParametersType & parameters) const;
00094 
00096   void GetDerivative(const ParametersType & parameters,
00097                      DerivativeType & Derivative) const;
00098 
00100   void GetValueAndDerivative(const ParametersType & parameters,
00101                              MeasureType & Value,
00102                              DerivativeType & Derivative) const;
00103 
00104 protected:
00105 
00106   MeanSquaresImageToImageMetric();
00107   virtual ~MeanSquaresImageToImageMetric();
00108   void PrintSelf(std::ostream & os, Indent indent) const;
00109 
00110 private:
00111 
00112   //purposely not implemented
00113   MeanSquaresImageToImageMetric(const Self &);
00114   //purposely not implemented
00115   void operator=(const Self &);
00116 
00117   inline bool GetValueThreadProcessSample(ThreadIdType threadID,
00118                                           SizeValueType fixedImageSample,
00119                                           const MovingImagePointType & mappedPoint,
00120                                           double movingImageValue) const;
00121 
00122   inline bool GetValueAndDerivativeThreadProcessSample(ThreadIdType threadID,
00123                                                        SizeValueType fixedImageSample,
00124                                                        const MovingImagePointType & mappedPoint,
00125                                                        double movingImageValue,
00126                                                        const ImageDerivativesType &
00127                                                        movingImageGradientValue) const;
00128 
00129   MeasureType *   m_ThreaderMSE;
00130   DerivativeType *m_ThreaderMSEDerivatives;
00131 };
00132 } // end namespace itk
00133 
00134 #ifndef ITK_MANUAL_INSTANTIATION
00135 #include "itkMeanSquaresImageToImageMetric.hxx"
00136 #endif
00137 
00138 #endif
00139