X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=registration%2FclitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h;fp=registration%2FclitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h;h=54503c5f15e7872d4b19cf803f3fffe52e048b89;hb=c18059db4f507fd31b5898667f57eced7d48c5f7;hp=0000000000000000000000000000000000000000;hpb=6e6c4206bc13210d5dd5dabf1bd24f17de316a7a;p=clitk.git diff --git a/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h new file mode 100644 index 0000000..54503c5 --- /dev/null +++ b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h @@ -0,0 +1,159 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#ifndef __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h +#define __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h + +#include "itkOptImageToImageMetric.h" +#include "itkCovariantVector.h" +#include "itkPoint.h" +#include "itkIndex.h" + +#include "itkMultiThreader.h" + +namespace clitk +{ + +template +class ITK_EXPORT NormalizedCorrelationImageToImageMetricFor3DBLUTFFD : + public itk::ImageToImageMetric< TFixedImage, TMovingImage > +{ +public: + + /** Standard class typedefs. */ + typedef NormalizedCorrelationImageToImageMetricFor3DBLUTFFD Self; + typedef itk::ImageToImageMetric< TFixedImage, TMovingImage > Superclass; + typedef itk::SmartPointer Pointer; + typedef itk::SmartPointer ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(NormalizedCorrelationImageToImageMetricFor3DBLUTFFD, ImageToImageMetric); + + /** Types inherited from Superclass. */ + typedef typename Superclass::RealType RealType; + typedef typename Superclass::TransformType TransformType; + typedef typename Superclass::TransformPointer TransformPointer; + typedef typename Superclass::TransformJacobianType TransformJacobianType; + typedef typename Superclass::InterpolatorType InterpolatorType; + typedef typename Superclass::MeasureType MeasureType; + typedef typename Superclass::DerivativeType DerivativeType; + typedef typename Superclass::ParametersType ParametersType; + typedef typename Superclass::FixedImageType FixedImageType; + typedef typename Superclass::MovingImageType MovingImageType; + typedef typename Superclass::MovingImagePointType MovingImagePointType; + typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer; + typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer; + typedef typename Superclass::CoordinateRepresentationType + CoordinateRepresentationType; + typedef typename Superclass::FixedImageSampleContainer + FixedImageSampleContainer; + typedef typename Superclass::ImageDerivativesType ImageDerivativesType; + typedef typename Superclass::WeightsValueType WeightsValueType; + typedef typename Superclass::IndexValueType IndexValueType; + + // Needed for evaluation of Jacobian. + typedef typename Superclass::FixedImagePointType FixedImagePointType; + + //Accumulators + typedef typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType; + + /** The moving image dimension. */ + itkStaticConstMacro( MovingImageDimension, unsigned int, + MovingImageType::ImageDimension ); + + + /** Set/Get SubtractMean boolean. If true, the sample mean is subtracted + * from the sample values in the cross-correlation formula and + * typically results in narrower valleys in the cost fucntion. + * Default value is false. */ + itkSetMacro( SubtractMean, bool ); + itkGetConstReferenceMacro( SubtractMean, bool ); + itkBooleanMacro( SubtractMean ); + + /** + * Initialize the Metric by + * (1) making sure that all the components are present and plugged + * together correctly, + * (2) uniformly select NumberOfSpatialSamples within + * the FixedImageRegion, and + * (3) allocate memory for pdf data structures. */ + virtual void Initialize(void) throw ( itk::ExceptionObject ); + + /** Get the value. */ + MeasureType GetValue( const ParametersType & parameters ) const; + + /** Get the derivatives of the match measure. */ + void GetDerivative( const ParametersType & parameters, + DerivativeType & Derivative ) const; + + /** Get the value and derivatives for single valued optimizers. */ + void GetValueAndDerivative( const ParametersType & parameters, + MeasureType & Value, + DerivativeType & Derivative ) const; + +protected: + + NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(); + virtual ~NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(); + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + + //purposely not implemented + NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(const Self &); + //purposely not implemented + void operator=(const Self &); + + /** Get the value for the derivative computation. */ + MeasureType ComputeSums( const ParametersType & parameters ) const; + + + inline bool GetValueThreadProcessSample( unsigned int threadID, + unsigned long fixedImageSample, + const MovingImagePointType & mappedPoint, + double movingImageValue ) const; + + + inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID, + unsigned long fixedImageSample, + const MovingImagePointType & mappedPoint, + double movingImageValue, + const ImageDerivativesType & + movingImageGradientValue ) const; + + AccumulateType *m_ThreaderSFF, *m_ThreaderSMM, *m_ThreaderSFM, *m_ThreaderSF, *m_ThreaderSM; + mutable AccumulateType m_SFF, m_SMM, m_SFM, m_SF, m_SM; + mutable RealType m_Denom, m_FixedMean, m_MovingMean; + DerivativeType * m_ThreaderDerivativeF, *m_ThreaderDerivativeM; + + + bool m_SubtractMean; +}; + +} // end namespace clitk + +#ifndef ITK_MANUAL_INSTANTIATION +#include "clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx" +#endif + +#endif + +