diff --git a/Code/Algorithms/ITK/CMakeLists.txt b/Code/Algorithms/ITK/CMakeLists.txt index d5c561c..dd01428 100644 --- a/Code/Algorithms/ITK/CMakeLists.txt +++ b/Code/Algorithms/ITK/CMakeLists.txt @@ -1,30 +1,31 @@ MAP_CREATE_MODULE(MAPAlgorithmsITK DEPENDS MAPAlgorithms MAPITK MAPUtilities) MAP_CREATE_MODULE_TESTS(MAPAlgorithmsITK PACKAGE_DEPENDS Litmus HEADER_TESTS) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKEuler3DMattesMI PROFILE "deployed/ITKEuler3DMattesMI.profile" FILES "deployed/mapITKEuler3DMattesMI.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKEuler3DMattesMIMultiRes PROFILE "deployed/ITKEuler3DMattesMIMultiRes.profile" FILES "deployed/mapITKEuler3DMattesMIMultiRes.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKEuler3DMS PROFILE "deployed/ITKEuler3DMS.profile" FILES "deployed/mapITKEuler3DMS.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigid2DMattesMI PROFILE "deployed/ITKRigid2DMattesMI.profile" FILES "deployed/mapITKRigid2DMattesMI.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigid2DMS PROFILE "deployed/ITKRigid2DMS.profile" FILES "deployed/mapITKRigid2DMS.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) +MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigid2DNTG PROFILE "deployed/ITKRigid2DNTG.profile" FILES "deployed/mapITKRigid2DNTG.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigid3DClosedForm PROFILE "deployed/ITKRigid3DClosedForm.profile" FILES "deployed/mapITKRigid3DClosedForm.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKPDEDemons3D PROFILE "deployed/ITKPDEDemons3D.profile" FILES "deployed/mapITKPDEDemons3D.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKLevelSetMotion3D PROFILE "deployed/ITKLevelSetMotion3D.profile" FILES "deployed/mapITKLevelSetMotion3D.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKSymmetricForcesDemons3D PROFILE "deployed/ITKSymmetricForcesDemons3D.profile" FILES "deployed/mapITKSymmetricForcesDemons3D.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKLevelSetMotion3DMultiRes PROFILE "deployed/ITKLevelSetMotion3DMultiRes.profile" FILES "deployed/mapITKLevelSetMotion3DMultiRes.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKTranslation3DMattesMIMultiRes PROFILE "deployed/ITKTranslation3DMattesMIMultiRes.profile" FILES "deployed/mapITKTranslation3DMattesMIMultiRes.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKAffine3DMattesMIMultiRes PROFILE "deployed/ITKAffine3DMattesMIMultiRes.profile" FILES "deployed/mapITKAffine3DMattesMIMultiRes.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigidHeadNeck PROFILE "deployed/ITKRigidHeadNeck.profile" FILES "deployed/mapITKRigidHeadNeck.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigidSlabbedHead PROFILE "deployed/ITKRigidSlabbedHead.profile" FILES "deployed/mapITKRigidSlabbedHead.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKRigid3DBoundingBox PROFILE "deployed/ITKRigid3DBoundingBox.profile" FILES "deployed/mapITKRigid3DBoundingBox.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) SET(_MAP_ITK_REVIEW_ACTIVE "OFF") MAP_CHECK_ITK_REVIEW_ACTIVE(_MAP_ITK_REVIEW_ACTIVE) IF (${_MAP_ITK_REVIEW_ACTIVE}) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKFastSymmetricForcesDemons3D PROFILE "deployed/ITKFastSymmetricForcesDemons3D.profile" FILES "deployed/mapITKFastSymmetricForcesDemons3D.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) MAP_DEFINE_DEPLOYED_ALGORITHM(ITKFastSymmetricForcesDemons3DMultiRes PROFILE "deployed/ITKFastSymmetricForcesDemons3DMultiRes.profile" FILES "deployed/mapITKFastSymmetricForcesDemons3DMultiRes.cpp" MODULE_DEPENDS MAPCore MAPAlgorithms MAPAlgorithmsITK MAPDeployment) ELSE (${_MAP_ITK_REVIEW_ACTIVE}) MESSAGE(WARNING "ITKReview Module is not activated. Following algorithms will not be deployed:\n - ITKFastSymmetricForcesDemons3D\n - ITKFastSymmetricForcesDemons3DMultiRes") ENDIF (${_MAP_ITK_REVIEW_ACTIVE}) \ No newline at end of file diff --git a/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.h b/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.h new file mode 100644 index 0000000..88edca1 --- /dev/null +++ b/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.h @@ -0,0 +1,118 @@ +// ----------------------------------------------------------------------- +// MatchPoint - DKFZ translational registration framework +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See mapCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision$ (last changed revision) +// @date $Date$ (last change date) +// @author $Author$ (last changed by) +// Subversion HeadURL: $HeadURL$ +*/ + + +#ifndef __MAP_ITK_RIGID2D_NTG_REGISTRATION_ALGORITHM_TEMPLATE_H +#define __MAP_ITK_RIGID2D_NTG_REGISTRATION_ALGORITHM_TEMPLATE_H + +#include "mapITKInitializedImageRegistrationAlgorithm.h" + +#include "mapITKRegularStepGradientDescentOptimizer.h" +#include "mapITKNormalizedTotalGradientImageToImageMetric.h" +#include "mapITKRigid2DTransform.h" +#include "mapITKLinearInterpolateImageFunction.h" + +#include "mapFixedImageToImageMetricPolicy.h" +#include "mapFixedInterpolatorPolicy.h" +#include "mapFixedSVNLOptimizerPolicy.h" +#include "mapFixedTransformPolicy.h" +#include "mapSealedImagePyramidesPolicy.h" +#include "mapNoComponentInitializationPolicy.h" + + + +namespace map +{ + namespace algorithm + { + namespace boxed + { + + mapGenerateAlgorithmUIDPolicyMacro(DefaultRigid2DNTGRegistrationAlgorithmUIDPolicy, + "de.dkfz.matchpoint", "Rigid2DNTGRegistrationAlgorithm.default", "1.1.0", ""); + + template < class TMovingImage, class TTargetImage = TMovingImage, + typename TUIDPolicy = DefaultRigid2DNTGRegistrationAlgorithmUIDPolicy, + class TInterpolatorPolicy = + SealedFixedInterpolatorPolicyMacro< ::itk::LinearInterpolateImageFunction > + > + class ITKRigid2DNTGRegistrationAlgorithm : + public algorithm::boxed::ITKInitializedImageRegistrationAlgorithm < TMovingImage, TTargetImage, + TUIDPolicy, + TInterpolatorPolicy, + SealedFixedImageToImageMetricPolicyMacro< ::itk::NormalizedTotalGradientImageToImageMetric >, + SealedFixedSVNLOptimizerPolicyMacro< ::itk::RegularStepGradientDescentOptimizer >, + SealedFixedTransformPolicyMacro< ::itk::Rigid2DTransform< ::map::core::continuous::ScalarType> > > + { + public: + typedef ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy > Self; + + typedef typename algorithm::boxed::ITKInitializedImageRegistrationAlgorithm < TMovingImage, + TTargetImage, + TUIDPolicy, + TInterpolatorPolicy, + SealedFixedImageToImageMetricPolicyMacro< ::itk::NormalizedTotalGradientImageToImageMetric >, + SealedFixedSVNLOptimizerPolicyMacro< ::itk::RegularStepGradientDescentOptimizer >, + SealedFixedTransformPolicyMacro< ::itk::Rigid2DTransform< ::map::core::continuous::ScalarType> > > + Superclass; + + typedef ::itk::SmartPointer Pointer; + typedef ::itk::SmartPointer ConstPointer; + + itkTypeMacro(ITKRigid2DNTGRegistrationAlgorithm, ITKImageRegistrationAlgorithm); + mapNewAlgorithmMacro(Self); + + typedef ::itk::Array ParametersType; + + typedef typename Superclass::MetaPropertyType MetaPropertyType; + typedef typename Superclass::MetaPropertyPointer MetaPropertyPointer; + typedef typename Superclass::MetaPropertyNameType MetaPropertyNameType; + typedef typename Superclass::MetaPropertyVectorType MetaPropertyVectorType; + + protected: + ITKRigid2DNTGRegistrationAlgorithm(); + virtual ~ITKRigid2DNTGRegistrationAlgorithm(); + + virtual void configureAlgorithm(); + + virtual void compileInfos(MetaPropertyVectorType& infos) const; + + virtual MetaPropertyPointer doGetProperty(const MetaPropertyNameType& name) const; + + virtual void doSetProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty); + + private: + + ITKRigid2DNTGRegistrationAlgorithm(const Self& source); //purposely not implemented + void operator=(const Self&); //purposely not implemented + }; + + } + } +} + +#ifndef MatchPoint_MANUAL_TPP +#include "mapITKRigid2DNTGRegistrationAlgorithmTemplate.tpp" +#endif + +#endif diff --git a/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.tpp b/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.tpp new file mode 100644 index 0000000..e0dd635 --- /dev/null +++ b/Code/Algorithms/ITK/boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.tpp @@ -0,0 +1,252 @@ +// ----------------------------------------------------------------------- +// MatchPoint - DKFZ translational registration framework +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See mapCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision$ (last changed revision) +// @date $Date$ (last change date) +// @author $Author$ (last changed by) +// Subversion HeadURL: $HeadURL$ +*/ + + +#ifndef __MAP_ITK_RIGID2D_NTG_REGISTRATION_ALGORITHM_TEMPLATE_TPP +#define __MAP_ITK_RIGID2D_NTG_REGISTRATION_ALGORITHM_TEMPLATE_TPP + +#include "mapITKRigid2DNTGRegistrationAlgorithmTemplate.h" + +#include "mapMetaProperty.h" +#include "mapMetaPropertyAccessor.h" + +#include "itkCenteredTransformInitializer.h" + +#include + +namespace map +{ + namespace algorithm + { + namespace boxed + { + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + ITKRigid2DNTGRegistrationAlgorithm() + { + }; + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + ~ITKRigid2DNTGRegistrationAlgorithm() + { + }; + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + void + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + configureAlgorithm() + { + this->_preInitialize = true; + this->_useCenterOfGravity = false; + + typename Superclass::ConcreteOptimizerType::ScalesType scales(3); + scales[0] = 1.0; + scales[1] = 1.0 / 1000; + scales[2] = 1.0 / 1000; + + //optimizer + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetScales(scales); + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetMaximumStepLength(2.00); + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetMinimumStepLength(0.001); + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetNumberOfIterations(200); + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetRelaxationFactor(0.8); + this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetGradientMagnitudeTolerance(1e-4); + + //transform + this->getConcreteTransformModel()->SetIdentity(); + + }; + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + void + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + compileInfos(MetaPropertyVectorType& infos) const + { + Superclass::compileInfos(infos); + + typedef typename Superclass::OptimizerBaseType::OptimizerBaseType::ScalesType ScalesType; + typedef typename Superclass::TransformBaseType::ParametersType ParametersType; + + #ifndef MAP_SEAL_ALGORITHMS + infos.push_back(::map::algorithm::MetaPropertyInfo::New("TransformParameters", typeid(ParametersType), + true, true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("FixedTransformParameters", + typeid(ParametersType), true, true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("Scales", typeid(ScalesType), true, true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("MaximumStepLength", typeid(double), true, + true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("MinimumStepLength", typeid(double), true, + true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("RelaxationFactor", typeid(double), true, + true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("NumberOfIterations", typeid(unsigned long), + true, true)); + infos.push_back(::map::algorithm::MetaPropertyInfo::New("GradientMagnitudeTolerance", typeid(double), + true, true)); + #endif + }; + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + typename ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >::MetaPropertyPointer + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + doGetProperty(const MetaPropertyNameType& name) const + { + MetaPropertyPointer spResult; + typedef typename Superclass::OptimizerBaseType::OptimizerBaseType::ScalesType ScalesType; + typedef typename Superclass::TransformBaseType::ParametersType ParametersType; + + if (name == "TransformParameters") + { + spResult = ::map::core::MetaProperty::New( + this->getTransformInternal()->GetParameters()); + } + else if (name == "FixedTransformParameters") + { + spResult = ::map::core::MetaProperty::New( + this->getTransformInternal()->GetFixedParameters()); + } + else if (name == "Scales") + { + spResult = ::map::core::MetaProperty::New(this->getConcreteITKOptimizer()->GetScales()); + } + else if (name == "MaximumStepLength") + { + spResult = ::map::core::MetaProperty::New( + this->getConcreteITKOptimizer()->GetMaximumStepLength()); + } + else if (name == "MinimumStepLength") + { + spResult = ::map::core::MetaProperty::New( + this->getConcreteITKOptimizer()->GetMinimumStepLength()); + } + else if (name == "RelaxationFactor") + { + spResult = ::map::core::MetaProperty::New( + this->getConcreteITKOptimizer()->GetRelaxationFactor()); + } + else if (name == "NumberOfIterations") + { + spResult = ::map::core::MetaProperty::New( + this->getConcreteITKOptimizer()->GetNumberOfIterations()); + } + else if (name == "GradientMagnitudeTolerance") + { + spResult = ::map::core::MetaProperty::New( + this->getConcreteITKOptimizer()->GetGradientMagnitudeTolerance()); + } + else + { + spResult = Superclass::doGetProperty(name); + } + + + return spResult; + }; + + template < class TMovingImage, class TTargetImage, + typename TUIDPolicy, + class TInterpolatorPolicy > + void + ITKRigid2DNTGRegistrationAlgorithm < TMovingImage, TTargetImage, TUIDPolicy, + TInterpolatorPolicy >:: + doSetProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty) + { + typedef typename Superclass::OptimizerBaseType::OptimizerBaseType::ScalesType ScalesType; + typedef typename Superclass::TransformBaseType::ParametersType ParametersType; + + if (name == "TransformParameters") + { + ParametersType params; + ::map::core::unwrapMetaProperty(pProperty, params); + this->getTransformInternal()->SetParameters(params); + } + else if (name == "FixedTransformParameters") + { + ParametersType params; + ::map::core::unwrapMetaProperty(pProperty, params); + this->getTransformInternal()->SetFixedParameters(params); + } + else if (name == "Scales") + { + ScalesType scales; + ::map::core::unwrapMetaProperty(pProperty, scales); + this->getConcreteITKOptimizer()->SetScales(scales); + } + else if (name == "MaximumStepLength") + { + double length; + ::map::core::unwrapMetaProperty(pProperty, length); + this->getConcreteITKOptimizer()->SetMaximumStepLength(length); + } + else if (name == "MinimumStepLength") + { + double length; + ::map::core::unwrapMetaProperty(pProperty, length); + this->getConcreteITKOptimizer()->SetMinimumStepLength(length); + } + else if (name == "RelaxationFactor") + { + double factor; + ::map::core::unwrapMetaProperty(pProperty, factor); + this->getConcreteITKOptimizer()->SetRelaxationFactor(factor); + } + else if (name == "NumberOfIterations") + { + unsigned long iterations; + ::map::core::unwrapMetaProperty(pProperty, iterations); + this->getConcreteITKOptimizer()->SetNumberOfIterations(iterations); + } + else if (name == "GradientMagnitudeTolerance") + { + double tolerance; + ::map::core::unwrapMetaProperty(pProperty, tolerance); + this->getConcreteITKOptimizer()->SetGradientMagnitudeTolerance(tolerance); + } + else + { + Superclass::doSetProperty(name, pProperty); + } + }; + + } + } +} + +#endif diff --git a/Code/Algorithms/ITK/deployed/ITKRigid2DNTG.profile b/Code/Algorithms/ITK/deployed/ITKRigid2DNTG.profile new file mode 100644 index 0000000..2a7214c --- /dev/null +++ b/Code/Algorithms/ITK/deployed/ITKRigid2DNTG.profile @@ -0,0 +1,19 @@ +SET(ALGORITHM_PROFILE_UID_Namespace "de.dkfz.matchpoint.common") +SET(ALGORITHM_PROFILE_UID_Name "Rigid2DNTGAlgorithm.2D.default") +SET(ALGORITHM_PROFILE_UID_Version "1.1.0") + +SET(ALGORITHM_PROFILE_Description "Simple 2D rigid (translation and rotation) registration algorithm using mean squares as metric.") +SET(ALGORITHM_PROFILE_Contact "Ralf Floca\; matchpoint@dkfz-heidelberg.de") + +SET(ALGORITHM_PROFILE_DataType "Image") +SET(ALGORITHM_PROFILE_DimMoving "2") +SET(ALGORITHM_PROFILE_ModalityMoving "any") +SET(ALGORITHM_PROFILE_DimTarget "2") +SET(ALGORITHM_PROFILE_ModalityTarget "any") +SET(ALGORITHM_PROFILE_Subject "any") +SET(ALGORITHM_PROFILE_Object "any") +SET(ALGORITHM_PROFILE_TransformModel "rigid") +SET(ALGORITHM_PROFILE_TransformDomain "global") +SET(ALGORITHM_PROFILE_Optimization "Regular Step Gradient Descent") +SET(ALGORITHM_PROFILE_Metric "Normalized Total Gradient") +SET(ALGORITHM_PROFILE_Keywords "basic, monomodal, rigid, 2D") diff --git a/Code/Algorithms/ITK/deployed/mapITKRigid2DNTG.cpp b/Code/Algorithms/ITK/deployed/mapITKRigid2DNTG.cpp new file mode 100644 index 0000000..1a1daf9 --- /dev/null +++ b/Code/Algorithms/ITK/deployed/mapITKRigid2DNTG.cpp @@ -0,0 +1,34 @@ +// ----------------------------------------------------------------------- +// MatchPoint - DKFZ translational registration framework +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See mapCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision$ (last changed revision) +// @date $Date$ (last change date) +// @author $Author$ (last changed by) +// Subversion HeadURL: $HeadURL$ +*/ + +#include "mapDeploymentDLLHelper.h" +#include "mapDiscreteElements.h" +#include "mapITKRigid2DNTGRegistrationAlgorithmTemplate.h" +#include "mapConfigure.h" + +#include "ITKRigid2DNTG_ProfileResource.h" + +typedef map::core::discrete::Elements<2>::InternalImageType ImageType; +typedef map::algorithm::boxed::ITKRigid2DNTGRegistrationAlgorithm +AlgorithmType; + +mapDeployAlgorithmMacro(AlgorithmType); \ No newline at end of file diff --git a/Code/Algorithms/ITK/files.cmake b/Code/Algorithms/ITK/files.cmake index 4f17de4..c7bd7a7 100644 --- a/Code/Algorithms/ITK/files.cmake +++ b/Code/Algorithms/ITK/files.cmake @@ -1,248 +1,251 @@ SET(CPP_FILES source/mapITKOptimizerControlInterface.cpp source/mapITKSVNLOptimizerControlInterface.cpp source/mapArbitrarySVNLOptimizerPolicy.cpp source/mapITKMetricControlInterface.cpp source/mapITKSVMetricControlInterface.cpp source/mapITKMVNLOptimizerControlInterface.cpp source/mapITKMVMetricControlInterface.cpp source/mapArbitraryMVNLOptimizerPolicy.cpp ) SET(H_FILES include/mapArbitraryInterpolatorPolicy.h include/mapArbitrarySVNLOptimizerPolicy.h include/mapFixedInterpolatorPolicy.h include/mapFixedSVNLOptimizerPolicy.h include/mapITKImageRegistrationAlgorithm.h include/mapITKImageRegistrationAlgorithmInterface.h include/mapITKInterpolatorSetterInterface.h include/mapITKImageToImageMetricSetterInterface.h include/mapITKSVNLOptimizerControlBase.h include/mapDefaultITKOptimizerControls.h include/mapITKOptimizerControlInterface.h include/mapITKSVNLOptimizerControlInterface.h include/mapITKSVNLOptimizerSetterInterface.h include/mapITKTransformSetterInterface.h include/mapArbitraryImageToImageMetricPolicy.h include/mapArbitraryTransformPolicy.h include/mapFixedImageToImageMetricPolicy.h include/mapFixedTransformPolicy.h include/mapITKMetricControlInterface.h include/mapITKSVMetricControlInterface.h include/mapITKImageToImageMetricControlInterface.h include/mapITKMetricControl.h include/mapITKImageToImageMetricControlBase.h include/mapITKMeanSquaresImageToImageMetric.h include/mapITKMattesMutualInformationImageToImageMetric.h include/mapITKCompareHistogramImageToImageMetric.h include/mapITKCorrelationCoefficientHistogramImageToImageMetric.h include/mapITKKappaStatisticImageToImageMetric.h include/mapITKGradientDifferenceImageToImageMetric.h include/mapITKMatchCardinalityImageToImageMetric.h include/mapITKMeanSquaresHistogramImageToImageMetric.h include/mapITKMutualInformationHistogramImageToImageMetric.h include/mapITKMutualInformationImageToImageMetric.h include/mapITKNormalizedCorrelationImageToImageMetric.h include/mapITKNormalizedMutualInformationHistogramImageToImageMetric.h +include/mapITKNormalizedTotalGradientImageToImageMetric.h include/mapITKAmoebaOptimizer.h include/mapITKPowellOptimizer.h include/mapITKRegularStepGradientDescentOptimizer.h include/mapITKConjugateGradientOptimizer.h include/mapITKFRPROptimizer.h include/mapITKGradientDescentOptimizer.h include/mapITKLBFGSBOptimizer.h include/mapITKLBFGSOptimizer.h include/mapITKOnePlusOneEvolutionaryOptimizer.h include/mapITKQuaternionRgidTransformGradientDescentOptimizer.h include/mapITKSPSAOptimizer.h include/mapITKVersorRigid3DTransformOptimizer.h include/mapITKVersorTransformOptimizer.h include/mapSealedInterpolatorPolicy.h include/mapSealedOptimizerPolicy.h include/mapSealedImageToImageMetricPolicy.h include/mapSealedTransformPolicy.h include/mapITKSVNLOptimizerGetterInterface.h include/mapITKInterpolatorGetterInterface.h include/mapITKImageToImageMetricGetterInterface.h include/mapITKTransformGetterInterface.h include/mapITKExhaustiveOptimizer.h include/mapITKLinearInterpolateImageFunction.h include/mapITKNearestNeighborInterpolateImageFunction.h include/mapITKBSplineInterpolateImageFunction.h include/mapITKWindowedSincInterpolateImageFunction.h include/mapITKMVNLOptimizerControlInterface.h include/mapITKPointSetToPointSetMetricControlBase.h include/mapITKPointSetToPointSetMetricControlInterface.h include/mapITKMVMetricControlInterface.h include/mapITKPointSetToPointSetMetricSetterInterface.h include/mapITKPointSetToPointSetMetricGetterInterface.h include/mapITKMVNLOptimizerSetterInterface.h include/mapITKMVNLOptimizerGetterInterface.h include/mapITKMVNLOptimizerControlBase.h include/mapArbitraryMVNLOptimizerPolicy.h include/mapFixedMVNLOptimizerPolicy.h include/mapArbitraryPointSetToPointSetMetricPolicy.h include/mapFixedPointSetToPointSetMetricPolicy.h include/mapSealedPointSetToPointSetMetricPolicy.h include/mapITKEuclideanDistancePointMetric.h include/mapITKEuclideanPairDistancePointMetric.h include/mapITKLevenbergMarquardtOptimizer.h include/mapITKMultiResImageRegistrationAlgorithm.h include/mapITKClosedFormRegistrationAlgorithm.h include/mapITKLandmarkKernelRegistrationAlgorithm.h include/mapITKPointSetRegistrationAlgorithm.h include/mapITKPDEDeformableRegistrationAlgorithmBase.h include/mapITKPDEDeformableRegistrationAlgorithm.h include/mapITKMultiResPDEDeformableRegistrationAlgorithm.h include/mapITKTranslationTransform.h include/mapITKScaleTransform.h include/mapITKAffineTransform.h include/mapITKAzimuthElevationToCartesianTransform.h include/mapITKCenteredAffineTransform.h include/mapITKElasticBodyReciprocalSplineKernelTransform.h include/mapITKElasticBodySplineKernelTransform.h include/mapITKFixedCenterOfRotationAffineTransform.h include/mapITKIdentityTransform.h include/mapITKKernelTransform.h include/mapITKScalableAffineTransform.h include/mapITKScaleLogarithmicTransform.h include/mapITKThinPlateR2LogRSplineKernelTransform.h include/mapITKThinPlateSplineKernelTransform.h include/mapITKVolumeSplineKernelTransform.h include/mapITKCenteredEuler3DTransform.h include/mapITKCenteredRigid2DTransform.h include/mapITKCenteredSimilarity2DTransform.h include/mapITKEuler2DTransform.h include/mapITKEuler3DTransform.h include/mapITKQuaternionRigidTransform.h include/mapITKRigid2DTransform.h include/mapITKRigid3DTransform.h include/mapITKRigid3DPerspectiveTransform.h include/mapITKScaleVersor3DTransform.h include/mapITKSimilarity2DTransform.h include/mapITKSimilarity3DTransform.h include/mapITKVersorRigid3DTransform.h include/mapITKVersorTransform.h include/mapITKBSplineDeformableTransform.h boxed/mapITKAffineMattesMIMultiResRegistrationAlgorithmTemplate.h boxed/mapITKDemonsRegistrationAlgorithm.h boxed/mapITKEuler3DICPRegistrationAlgorithmTemplate.h boxed/mapITKEuler3DMattesMIMultiResRegistrationAlgorithmTemplate.h boxed/mapITKEuler3DMattesMIRegistrationAlgorithmTemplate.h boxed/mapITKEuler3DMSRegistrationAlgorithmTemplate.h boxed/mapITKInitializedImageRegistrationAlgorithm.h boxed/mapITKInitializedMultiResImageRegistrationAlgorithm.h boxed/mapITKRigid2DClosedFormRegistrationAlgorithmTemplate.h boxed/mapITKRigid2DICPRegistrationAlgorithmTemplate.h boxed/mapITKRigid3DICPRegistrationAlgorithmTemplate.h boxed/mapITKRigid2DMattesMIRegistrationAlgorithmTemplate.h boxed/mapITKRigid2DMSRegistrationAlgorithmTemplate.h +boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.h boxed/mapITKRigid3DClosedFormRegistrationAlgorithmTemplate.h boxed/mapTransMSRegistrationAlgorithmTemplate.h boxed/mapTransMattesMIRegistrationAlgorithmTemplate.h boxed/mapITKTransMattesMIMultiResRegistrationAlgorithm.h boxed/mapITKPDEDemonsRegistrationAlgorithm.h boxed/mapITKLevelSetMotionRegistrationAlgorithm.h boxed/mapITKSymmetricForcesDemonsRegistrationAlgorithm.h boxed/mapITKLevelSetMotionMultiResRegistrationAlgorithm.h boxed/mapITKRigid3DMattesMIHeadNeckRegistrationAlgorithmTemplate.h boxed/mapITKRigid3DMattesMISlabbedHeadRegistrationAlgorithmTemplate.h boxed/mapITKRigid3DMattesMIBoundingBoxRegistrationAlgorithmTemplate.h ) SET(TPP_FILES include/mapITKImageRegistrationAlgorithm.tpp include/mapITKImageRegistrationAlgorithmInterface.tpp include/mapITKSVNLOptimizerControlBase.tpp include/mapITKMVNLOptimizerControlBase.tpp include/mapArbitraryInterpolatorPolicy.tpp include/mapArbitraryImageToImageMetricPolicy.tpp include/mapArbitraryTransformPolicy.tpp include/mapFixedInterpolatorPolicy.tpp include/mapFixedImageToImageMetricPolicy.tpp include/mapFixedSVNLOptimizerPolicy.tpp include/mapFixedTransformPolicy.tpp include/mapITKImageToImageMetricControlBase.tpp include/mapSealedInterpolatorPolicy.tpp include/mapSealedOptimizerPolicy.tpp include/mapSealedImageToImageMetricPolicy.tpp include/mapSealedTransformPolicy.tpp include/mapITKPointSetToPointSetMetricControlBase.tpp include/mapFixedMVNLOptimizerPolicy.tpp include/mapArbitraryPointSetToPointSetMetricPolicy.tpp include/mapFixedPointSetToPointSetMetricPolicy.tpp include/mapSealedPointSetToPointSetMetricPolicy.tpp include/mapITKPointSetRegistrationAlgorithm.tpp include/mapITKPointSetRegistrationAlgorithmInterface.tpp include/mapITKMultiResImageRegistrationAlgorithm.tpp include/mapITKClosedFormRegistrationAlgorithm.tpp include/mapITKLandmarkKernelRegistrationAlgorithm.tpp include/mapITKPointSetRegistrationAlgorithm.tpp include/mapITKPDEDeformableRegistrationAlgorithmBase.tpp include/mapITKPDEDeformableRegistrationAlgorithm.tpp include/mapITKMultiResPDEDeformableRegistrationAlgorithm.tpp boxed/mapITKAffineMattesMIMultiResRegistrationAlgorithmTemplate.tpp boxed/mapITKDemonsRegistrationAlgorithm.tpp boxed/mapITKEuler3DMattesMIMultiResRegistrationAlgorithmTemplate.tpp boxed/mapITKEuler3DMattesMIRegistrationAlgorithmTemplate.tpp boxed/mapITKEuler3DMSRegistrationAlgorithmTemplate.tpp boxed/mapITKTransMattesMIMultiResRegistrationAlgorithm.tpp boxed/mapITKInitializedImageRegistrationAlgorithm.tpp boxed/mapITKInitializedMultiResImageRegistrationAlgorithm.tpp boxed/mapITKRigid2DMattesMIRegistrationAlgorithmTemplate.tpp +boxed/mapITKRigid2DNTGRegistrationAlgorithmTemplate.tpp boxed/mapITKPDEDemonsRegistrationAlgorithm.tpp boxed/mapITKLevelSetMotionRegistrationAlgorithm.tpp boxed/mapITKSymmetricForcesDemonsRegistrationAlgorithm.tpp boxed/mapITKLevelSetMotionMultiResRegistrationAlgorithm.tpp boxed/mapITKRigid3DMattesMIHeadNeckRegistrationAlgorithmTemplate.tpp boxed/mapITKRigid3DMattesMISlabbedHeadRegistrationAlgorithmTemplate.tpp boxed/mapITKRigid3DMattesMIBoundingBoxRegistrationAlgorithmTemplate.tpp ) SET(TEST_CPP_FILES test/mapAlgorithmsITKTests.cpp test/mapITKOptimizerControlInterfaceTest.cpp test/mapITKOptimizerControlTest.cpp test/mapFixedSVNLOptimizerPolicyTest.cpp test/mapArbitrarySVNLOptimizerPolicyTest.cpp test/mapFixedInterpolatorPolicyTest.cpp test/mapArbitraryInterpolatorPolicyTest.cpp test/mapFixedImageToImageMetricPolicyTest.cpp test/mapArbitraryImageToImageMetricPolicyTest.cpp test/mapFixedTransformPolicyTest.cpp test/mapArbitraryTransformPolicyTest.cpp test/mapITKImageRegistrationAlgorithmTest.cpp test/mapFixedITKImageRegistrationAlgorithmTest.cpp test/mapArbitraryMVNLOptimizerPolicyTest.cpp test/mapFixedMVNLOptimizerPolicyTest.cpp test/mapArbitraryPointSetToPointSetMetricPolicyTest.cpp test/mapFixedPointSetToPointSetMetricPolicyTest.cpp test/mapITKPointSetRegistrationAlgorithmTest.cpp test/mapITKRigid2DICPRegistrationAlgorithmTemplateTest.cpp test/mapITKEuler3DICPRegistrationAlgorithmTemplateTest.cpp test/mapITKRigid2DClosedFormRegistrationAlgorithmTemplateTest.cpp test/mapITKRigid3DClosedFormRegistrationAlgorithmTemplateTest.cpp test/mapITKLandmarkKernelRegistrationAlgorithmTest.cpp test/mapITKEuler3DMattesMIRegistrationAlgorithmTemplateTest.cpp test/mapITKTransMattesMIMultiResRegistrationAlgorithmTest.cpp ) SET(_MAP_ITK_REVIEW_ACTIVE "OFF") MAP_CHECK_ITK_REVIEW_ACTIVE(_MAP_ITK_REVIEW_ACTIVE) IF (${_MAP_ITK_REVIEW_ACTIVE}) SET(H_FILES ${H_FILES} include/mapITKComplexBSplineInterpolateImageFunction.h boxed/mapITKFastSymmetricForcesDemonsRegistrationAlgorithm.h boxed/mapITKFastSymmetricForcesDemonsMultiResRegistrationAlgorithm.h) SET(TPP_FILES ${TPP_FILES} boxed/mapITKFastSymmetricForcesDemonsMultiResRegistrationAlgorithm.tpp boxed/mapITKFastSymmetricForcesDemonsRegistrationAlgorithm.tpp) ELSE (${_MAP_ITK_REVIEW_ACTIVE}) MESSAGE(WARNING "ITKReview Module is not activated. Dependend resources will be deactivated:\n - mapITKComplexBSplineInterpolateImageFunction.h\n - mapITKFastSymmetricForcesDemonsRegistrationAlgorithm\n - mapITKFastSymmetricForcesDemonsMultiResRegistrationAlgorithm") ENDIF (${_MAP_ITK_REVIEW_ACTIVE}) \ No newline at end of file diff --git a/Code/Algorithms/ITK/include/mapITKNormalizedTotalGradientImageToImageMetric.h b/Code/Algorithms/ITK/include/mapITKNormalizedTotalGradientImageToImageMetric.h new file mode 100644 index 0000000..93aa350 --- /dev/null +++ b/Code/Algorithms/ITK/include/mapITKNormalizedTotalGradientImageToImageMetric.h @@ -0,0 +1,85 @@ +// ----------------------------------------------------------------------- +// MatchPoint - DKFZ translational registration framework +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See mapCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision$ (last changed revision) +// @date $Date$ (last change date) +// @author $Author$ (last changed by) +// Subversion HeadURL: $HeadURL$ +*/ + + + + +#ifndef __MAP_ITK_NORMALIZED_TOTAL_GRADIENT_IMAGE_TO_IMAGE_METRIC_CONTROL_H +#define __MAP_ITK_NORMALIZED_TOTAL_GRADIENT_IMAGE_TO_IMAGE_METRIC_CONTROL_H + +#include "mapITKMetricControl.h" +#include "mapITKImageToImageMetricControlBase.h" +#include "mapNormalizedTotalGradientImageToImageMetric.h" + +namespace map +{ + namespace algorithm + { + namespace itk + { + using LightObject = ::itk::LightObject; + + /*! + This class is the template specialization for the itk::NormalizedTotalGradientImageToImageMetric. + @ingroup ITK + @ingroup MetricControl + */ + template + class ITKMetricControl< ::itk::NormalizedTotalGradientImageToImageMetric > : public + ITKImageToImageMetricControlBase< ::itk::NormalizedTotalGradientImageToImageMetric > + { + public: + typedef ITKMetricControl< ::itk::NormalizedTotalGradientImageToImageMetric > + Self; + typedef ITKImageToImageMetricControlBase< ::itk::NormalizedTotalGradientImageToImageMetric > + Superclass; + typedef ::itk::SmartPointer Pointer; + typedef ::itk::SmartPointer ConstPointer; + + itkTypeMacro(ITKMetricControl, ITKImageToImageMetricControlBase); + itkNewMacro(Self); + + virtual bool getMinimizeToOptimize() const + { + return true; + }; + + virtual bool getMaximizeToOptimize() const + { + return false; + }; + + protected: + virtual ~ITKMetricControl() {}; + ITKMetricControl() {}; + + private: + //No copy constructor allowed + ITKMetricControl(const Self& source); + void operator=(const Self&); //purposely not implemented + }; + + } + } +} + +#endif diff --git a/Code/ITK/files.cmake b/Code/ITK/files.cmake index 018a1a8..67095fa 100644 --- a/Code/ITK/files.cmake +++ b/Code/ITK/files.cmake @@ -1,24 +1,26 @@ SET(CPP_FILES ) SET(H_FILES include/mapArbitraryWarpImageFilter.h include/mapEuclideanPairDistancePointMetric.h include/mapIterativeInverseTransformToDisplacementFieldSource.h +include/mapNormalizedTotalGradientImageToImageMetric.h include/mapNULLVectorAwareLinearInterpolateImageFunction.h include/itkMatrixOffsetBasedTranslationTransform.h include/itkImageTransformHelper.h ) SET(TPP_FILES include/mapArbitraryWarpImageFilter.txx include/mapEuclideanPairDistancePointMetric.txx include/mapIterativeInverseTransformToDisplacementFieldSource.txx include/mapNULLVectorAwareLinearInterpolateImageFunction.tpp +include/mapNormalizedTotalGradientImageToImageMetric.tpp include/itkMatrixOffsetBasedTranslationTransform.hxx ) SET(TEST_CPP_FILES test/mapIterativeInverseTransformToDisplacementFieldSourceTest.cpp test/mapITKTests.cpp ) \ No newline at end of file diff --git a/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.h b/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.h new file mode 100644 index 0000000..3008402 --- /dev/null +++ b/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.h @@ -0,0 +1,119 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef mapNormalizedTotalGradientImageToImageMetric_h +#define mapNormalizedTotalGradientImageToImageMetric_h + +#include "itkImageToImageMetric.h" +#include "itkPoint.h" +#include "itkIndex.h" + +#include // For unique_ptr. + + +namespace itk +{ + +/** + * \class NormalizedTotalGradientImageToImageMetric + * \brief TODO + * \ingroup ITKRegistrationCommon + * + * \sphinx + * \sphinxexample{Registration/Common/ComputeMeanSquareBetweenTwoImages,Compute Mean Squares Metric Between Two Images} + * \endsphinx + */ +template +class ITK_TEMPLATE_EXPORT NormalizedTotalGradientImageToImageMetric : public ImageToImageMetric +{ +public: + ITK_DISALLOW_COPY_AND_MOVE(NormalizedTotalGradientImageToImageMetric); + + /** Standard class type aliases. */ + using Self = NormalizedTotalGradientImageToImageMetric; + using Superclass = ImageToImageMetric; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(NormalizedTotalGradientImageToImageMetric, ImageToImageMetric); + + /** Types inherited from Superclass. */ + using typename Superclass::TransformType; + using typename Superclass::TransformPointer; + using typename Superclass::TransformJacobianType; + using typename Superclass::InterpolatorType; + using typename Superclass::MeasureType; + using typename Superclass::DerivativeType; + using typename Superclass::ParametersType; + using typename Superclass::FixedImageType; + using typename Superclass::MovingImageType; + using typename Superclass::MovingImagePointType; + using typename Superclass::FixedImageConstPointer; + using typename Superclass::MovingImageConstPointer; + using typename Superclass::CoordinateRepresentationType; + using typename Superclass::FixedImageSampleContainer; + using typename Superclass::ImageDerivativesType; + using typename Superclass::WeightsValueType; + using typename Superclass::IndexValueType; + + // Needed for evaluation of Jacobian. + using typename Superclass::FixedImagePointType; + + /** The moving image dimension. */ + static constexpr unsigned int MovingImageDimension = MovingImageType::ImageDimension; + + /** + * Initialize the Metric by + * (1) making sure that all the components are present and plugged + * together correctly, + * (2) prepare everything "global" needed for computation*/ + void + Initialize() override; + + /** Get the value. */ + MeasureType + GetValue(const ParametersType& parameters) const override; + + /** Get the derivatives of the match measure. */ + void + GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const override; + + /** Get the value and derivatives for single valued optimizers. */ + void + GetValueAndDerivative(const ParametersType& parameters, + MeasureType& value, + DerivativeType& derivative) const override; + +protected: + NormalizedTotalGradientImageToImageMetric(); + ~NormalizedTotalGradientImageToImageMetric() override = default; + void + PrintSelf(std::ostream& os, Indent indent) const override; + +}; + +} // end namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +# include "mapNormalizedTotalGradientImageToImageMetric.hxx" +#endif + +#endif diff --git a/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.hxx b/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.hxx new file mode 100644 index 0000000..7793601 --- /dev/null +++ b/Code/ITK/include/mapNormalizedTotalGradientImageToImageMetric.hxx @@ -0,0 +1,133 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef itkNormalizedTotalGradientImageToImageMetric_hxx +#define itkNormalizedTotalGradientImageToImageMetric_hxx + +#include "itkCovariantVector.h" +#include "itkImageRegionIterator.h" +#include "itkImageIterator.h" +#include "itkMath.h" +#include "itkMakeUniqueForOverwrite.h" + +namespace itk +{ +/** + * Constructor + */ +template +NormalizedTotalGradientImageToImageMetric::NormalizedTotalGradientImageToImageMetric() +{ + this->SetComputeGradient(true); + + this->m_WithinThreadPreProcess = false; + this->m_WithinThreadPostProcess = false; + + // For backward compatibility, the default behavior is to use all the pixels + // in the fixed image. + // This should be fixed in ITKv4 so that this metric behaves as the others. + this->SetUseAllPixels(true); +} + +/** + * Print out internal information about this class + */ +template +void +NormalizedTotalGradientImageToImageMetric::PrintSelf(std::ostream & os, Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +/** + * Initialize + */ +template +void +NormalizedTotalGradientImageToImageMetric::Initialize() +{ + this->Superclass::Initialize(); + +} + +template +auto +NormalizedTotalGradientImageToImageMetric::GetValue(const ParametersType & parameters) const + -> MeasureType +{ + itkDebugMacro("GetValue( " << parameters << " ) "); + + if (!this->m_FixedImage) + { + itkExceptionMacro(<< "Fixed image has not been assigned"); + } + + if (!this->m_MovingImage) + { + itkExceptionMacro(<< "Moving image has not been assigned"); + } + + // Set up the parameters in the transform + this->m_Transform->SetParameters(parameters); + + //do the computation based on Fixed and moving images + //Mask support can be skipped for now I suppose, but should be statet if not implemented in the class docu. + + //TODO +} + + +/** + * Get the both Value and Derivative Measure + */ +template +void +NormalizedTotalGradientImageToImageMetric::GetValueAndDerivative(const ParametersType & parameters, + MeasureType & value, + DerivativeType & derivative) const +{ + if (!this->m_FixedImage) + { + itkExceptionMacro(<< "Fixed image has not been assigned"); + } + + // Set up the parameters in the transform + this->m_Transform->SetParameters(parameters); + throw "not implemented yet"; +} + +/** + * Get the match measure derivative + */ +template +void +NormalizedTotalGradientImageToImageMetric::GetDerivative(const ParametersType & parameters, + DerivativeType & derivative) const +{ + if (!this->m_FixedImage) + { + itkExceptionMacro(<< "Fixed image has not been assigned"); + } + + MeasureType value; + // call the combined version + this->GetValueAndDerivative(parameters, value, derivative); +} + +} // end namespace itk + +#endif