From 524d2a38c290b224ebfad3bbc89ece326286507c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 24 Jun 2026 16:47:29 +0200 Subject: [PATCH] STYLE: Remove ImageToImageMetricWithFeatures from Common/CostFunctions It appears unused. It wasn't even included with compilation. --- Common/CMakeLists.txt | 2 - .../itkImageToImageMetricWithFeatures.h | 262 ------------- .../itkImageToImageMetricWithFeatures.hxx | 359 ------------------ 3 files changed, 623 deletions(-) delete mode 100644 Common/CostFunctions/itkImageToImageMetricWithFeatures.h delete mode 100644 Common/CostFunctions/itkImageToImageMetricWithFeatures.hxx diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt index 007545d5e..1cfcd4ce5 100644 --- a/Common/CMakeLists.txt +++ b/Common/CMakeLists.txt @@ -70,8 +70,6 @@ set(CostFunctionFiles CostFunctions/itkExponentialLimiterFunction.hxx CostFunctions/itkHardLimiterFunction.h CostFunctions/itkHardLimiterFunction.hxx - CostFunctions/itkImageToImageMetricWithFeatures.h - CostFunctions/itkImageToImageMetricWithFeatures.hxx CostFunctions/itkLimiterFunctionBase.h CostFunctions/itkMultiInputImageToImageMetricBase.h CostFunctions/itkMultiInputImageToImageMetricBase.hxx diff --git a/Common/CostFunctions/itkImageToImageMetricWithFeatures.h b/Common/CostFunctions/itkImageToImageMetricWithFeatures.h deleted file mode 100644 index 2af0c4ab7..000000000 --- a/Common/CostFunctions/itkImageToImageMetricWithFeatures.h +++ /dev/null @@ -1,262 +0,0 @@ -/*========================================================================= - * - * Copyright UMC Utrecht and contributors - * - * 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 - * - * http://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 itkImageToImageMetricWithFeatures_h -#define itkImageToImageMetricWithFeatures_h - -#include "itkAdvancedImageToImageMetric.h" -#include "itkInterpolateImageFunction.h" - -namespace itk -{ - -/** \class ImageToImageMetricWithFeatures - * \brief Computes similarity between regions of two images. - * - * This base class adds functionality that makes it possible - * to use fixed and moving image features. - * - * \ingroup RegistrationMetrics - * - */ - -template -class ITK_TEMPLATE_EXPORT ImageToImageMetricWithFeatures : public AdvancedImageToImageMetric -{ -public: - ITK_DISALLOW_COPY_AND_MOVE(ImageToImageMetricWithFeatures); - - /** Standard class typedefs. */ - using Self = ImageToImageMetricWithFeatures; - using Superclass = AdvancedImageToImageMetric; - using Pointer = SmartPointer; - using ConstPointer = SmartPointer; - - /** Run-time type information (and related methods). */ - itkOverrideGetNameOfClassMacro(ImageToImageMetricWithFeatures); - - /** Typedefs from the superclass. */ - using typename Superclass::CoordinateRepresentationType; - using typename Superclass::MovingImageType; - using typename Superclass::MovingImagePixelType; - using typename Superclass::MovingImageConstPointer; - using typename Superclass::FixedImageType; - using typename Superclass::FixedImageConstPointer; - using typename Superclass::FixedImageRegionType; - using typename Superclass::TransformType; - using typename Superclass::TransformPointer; - using typename Superclass::InputPointType; - using typename Superclass::OutputPointType; - using typename Superclass::TransformParametersType; - using typename Superclass::TransformJacobianType; - using typename Superclass::InterpolatorType; - using typename Superclass::InterpolatorPointer; - using typename Superclass::RealType; - using typename Superclass::GradientPixelType; - using typename Superclass::GradientImageType; - using typename Superclass::GradientImagePointer; - using typename Superclass::FixedImageMaskType; - using typename Superclass::FixedImageMaskPointer; - using typename Superclass::MovingImageMaskType; - using typename Superclass::MovingImageMaskPointer; - using typename Superclass::MeasureType; - using typename Superclass::DerivativeType; - using typename Superclass::ParametersType; - using typename Superclass::FixedImagePixelType; - using typename Superclass::MovingImageRegionType; - using typename Superclass::ImageSamplerType; - using typename Superclass::ImageSamplerPointer; - using typename Superclass::ImageSampleContainerType; - using typename Superclass::ImageSampleContainerPointer; - using typename Superclass::InternalMaskPixelType; - using typename Superclass::InternalMovingImageMaskType; - using typename Superclass::MovingImageMaskInterpolatorType; - using typename Superclass::FixedImageLimiterType; - using typename Superclass::MovingImageLimiterType; - using typename Superclass::FixedImageLimiterOutputType; - using typename Superclass::MovingImageLimiterOutputType; - - /** The fixed image dimension. */ - itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension); - - /** The moving image dimension. */ - itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension); - - /** Typedefs for the feature images. */ - using FixedFeatureImageType = TFixedFeatureImage; - using FixedFeatureImagePointer = typename FixedFeatureImageType::Pointer; - using MovingFeatureImageType = TMovingFeatureImage; - using MovingFeatureImagePointer = typename MovingFeatureImageType::Pointer; - using FixedFeatureImageVectorType = std::vector; - using MovingFeatureImageVectorType = std::vector; - - /** Typedefs for the feature images interpolators. */ - using FixedFeatureInterpolatorType = InterpolateImageFunction; - using MovingFeatureInterpolatorType = InterpolateImageFunction; - using FixedFeatureInterpolatorPointer = typename FixedFeatureInterpolatorType::Pointer; - using MovingFeatureInterpolatorPointer = typename MovingFeatureInterpolatorType::Pointer; - using FixedFeatureInterpolatorVectorType = std::vector; - using MovingFeatureInterpolatorVectorType = std::vector; - - /** Set the number of fixed feature images. */ - void - SetNumberOfFixedFeatureImages(unsigned int arg); - - /** Get the number of fixed feature images. */ - itkGetConstMacro(NumberOfFixedFeatureImages, unsigned int); - - /** Functions to set the fixed feature images. */ - void - SetFixedFeatureImage(unsigned int i, FixedFeatureImageType * im); - - void - SetFixedFeatureImage(FixedFeatureImageType * im) - { - this->SetFixedFeatureImage(0, im); - } - - - /** Functions to get the fixed feature images. */ - const FixedFeatureImageType * - GetFixedFeatureImage(unsigned int i) const; - - const FixedFeatureImageType * - GetFixedFeatureImage() const - { - return this->GetFixedFeatureImage(0); - } - - - /** Functions to set the fixed feature interpolators. */ - void - SetFixedFeatureInterpolator(unsigned int i, FixedFeatureInterpolatorType * interpolator); - - void - SetFixedFeatureInterpolator(FixedFeatureInterpolatorType * interpolator) - { - this->SetFixedFeatureInterpolator(0, interpolator); - } - - - /** Functions to get the fixed feature interpolators. */ - const FixedFeatureInterpolatorType * - GetFixedFeatureInterpolator(unsigned int i) const; - - const FixedFeatureInterpolatorType * - GetFixedFeatureInterpolator() const - { - return this->GetFixedFeatureInterpolator(0); - } - - - /** Set the number of moving feature images. */ - void - SetNumberOfMovingFeatureImages(unsigned int arg); - - /** Get the number of moving feature images. */ - itkGetConstMacro(NumberOfMovingFeatureImages, unsigned int); - - /** Functions to set the moving feature images. */ - void - SetMovingFeatureImage(unsigned int i, MovingFeatureImageType * im); - - void - SetMovingFeatureImage(MovingFeatureImageType * im) - { - this->SetMovingFeatureImage(0, im); - } - - - /** Functions to get the moving feature images. */ - const MovingFeatureImageType * - GetMovingFeatureImage(unsigned int i) const; - - const MovingFeatureImageType * - GetMovingFeatureImage() const - { - return this->GetMovingFeatureImage(0); - } - - - /** Functions to set the moving feature interpolators. */ - void - SetMovingFeatureInterpolator(unsigned int i, MovingFeatureInterpolatorType * interpolator); - - void - SetMovingFeatureInterpolator(MovingFeatureInterpolatorType * interpolator) - { - this->SetMovingFeatureInterpolator(0, interpolator); - } - - - /** Functions to get the moving feature interpolators. */ - const MovingFeatureInterpolatorType * - GetMovingFeatureInterpolator(unsigned int i) const; - - const MovingFeatureInterpolatorType * - GetMovingFeatureInterpolator() const - { - return this->GetMovingFeatureInterpolator(0); - } - - - /** Initialize the metric. */ - virtual void - Initialize(); - -protected: - ImageToImageMetricWithFeatures() = default; - virtual ~ImageToImageMetricWithFeatures() {} - void - PrintSelf(std::ostream & os, Indent indent) const; - - using typename Superclass::BSplineInterpolatorType; - using BSplineInterpolatorPointer = typename BSplineInterpolatorType::Pointer; - using BSplineFeatureInterpolatorVectorType = std::vector; - using typename Superclass::FixedImagePointType; - using typename Superclass::MovingImagePointType; - using typename Superclass::MovingImageDerivativeType; - using typename Superclass::MovingImageContinuousIndexType; - - /** Member variables. */ - unsigned int m_NumberOfFixedFeatureImages{ 0 }; - unsigned int m_NumberOfMovingFeatureImages{ 0 }; - FixedFeatureImageVectorType m_FixedFeatureImages{}; - MovingFeatureImageVectorType m_MovingFeatureImages{}; - FixedFeatureInterpolatorVectorType m_FixedFeatureInterpolators{}; - MovingFeatureInterpolatorVectorType m_MovingFeatureInterpolators{}; - - std::vector m_FeatureInterpolatorsIsBSpline{}; - BSplineFeatureInterpolatorVectorType m_MovingFeatureBSplineInterpolators{}; - - /** Initialize variables for image derivative computation; this - * method is called by Initialize. - */ - virtual void - CheckForBSplineFeatureInterpolators(); -}; - -} // end namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -# include "itkImageToImageMetricWithFeatures.hxx" -#endif - -#endif // end #ifndef itkImageToImageMetricWithFeatures_h diff --git a/Common/CostFunctions/itkImageToImageMetricWithFeatures.hxx b/Common/CostFunctions/itkImageToImageMetricWithFeatures.hxx deleted file mode 100644 index 5377bff4f..000000000 --- a/Common/CostFunctions/itkImageToImageMetricWithFeatures.hxx +++ /dev/null @@ -1,359 +0,0 @@ -/*========================================================================= - * - * Copyright UMC Utrecht and contributors - * - * 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 - * - * http://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 _itkImageToImageMetricWithFeatures_hxx -#define _itkImageToImageMetricWithFeatures_hxx - -#include "itkImageToImageMetricWithFeatures.h" - -namespace itk -{ - -/** - * ********************* Initialize ***************************** - */ - -template -void -ImageToImageMetricWithFeatures::Initialize() -{ - /** Call the superclass. */ - this->Superclass::Initialize(); - - /** Check the fixed stuff. */ - for (unsigned int i = 0; i < m_NumberOfFixedFeatureImages; ++i) - { - /** Check if all the fixed feature images are set. */ - if (!this->m_FixedFeatureImages[i]) - { - itkExceptionMacro("ERROR: fixed feature image " << i << " is not set."); - } - /** Check if all the fixed feature interpolators are set. */ - if (!this->m_FixedFeatureInterpolators[i]) - { - itkExceptionMacro("ERROR: fixed feature interpolator " << i << " is not set."); - } - /** Connect the feature image to the interpolator. */ - this->m_FixedFeatureInterpolators[i]->SetInputImage(this->m_FixedFeatureImages[i]); - } - - /** Check the moving stuff. */ - for (unsigned int i = 0; i < m_NumberOfMovingFeatureImages; ++i) - { - /** Check if all the moving feature images are set. */ - if (!this->m_MovingFeatureImages[i]) - { - itkExceptionMacro("ERROR: moving feature image " << i << " is not set."); - } - /** Check if all the moving feature interpolators are set. */ - if (!this->m_MovingFeatureInterpolators[i]) - { - itkExceptionMacro("ERROR: moving feature interpolator " << i << " is not set."); - } - /** Connect the feature image to the interpolator. */ - this->m_MovingFeatureInterpolators[i]->SetInputImage(this->m_MovingFeatureImages[i]); - } - - /** Check if the moving feature image interpolators are B-spline interpolators. */ - this->CheckForBSplineFeatureInterpolators(); - -} // end Initialize() - - -/** - * ********************* SetNumberOfFixedFeatureImages **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetNumberOfFixedFeatureImages(unsigned int arg) -{ - if (this->m_NumberOfFixedFeatureImages != arg) - { - this->m_FixedFeatureImages.resize(arg); - this->m_FixedFeatureInterpolators.resize(arg); - this->m_NumberOfFixedFeatureImages = arg; - this->Modified(); - } - -} // end SetNumberOfFixedFeatureImages() - - -/** - * ********************* SetFixedFeatureImage **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetFixedFeatureImage(unsigned int i, FixedFeatureImageType * im) -{ - if (i + 1 > this->m_NumberOfFixedFeatureImages) - { - this->m_FixedFeatureImages.resize(i + 1); - this->m_FixedFeatureImages[i] = im; - this->m_NumberOfFixedFeatureImages = i; - this->Modified(); - } - else - { - if (this->m_FixedFeatureImages[i] != im) - { - this->m_FixedFeatureImages[i] = im; - this->Modified(); - } - } - -} // end SetFixedFeatureImage() - - -/** - * ********************* GetFixedFeatureImage **************************** - */ - -template -const typename ImageToImageMetricWithFeatures:: - FixedFeatureImageType * - ImageToImageMetricWithFeatures:: - GetFixedFeatureImage(unsigned int i) const -{ - return this->m_FixedFeatureImages[i].GetPointer(); -} // end GetFixedFeatureImage() - -/** - * ********************* SetFixedFeatureInterpolator **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetFixedFeatureInterpolator(unsigned int i, FixedFeatureInterpolatorType * interpolator) -{ - if (i + 1 > this->m_NumberOfFixedFeatureImages) - { - this->m_FixedFeatureInterpolators.resize(i + 1); - this->m_FixedFeatureInterpolators[i] = interpolator; - this->m_NumberOfFixedFeatureImages = i; - this->Modified(); - } - else - { - if (this->m_FixedFeatureInterpolators[i] != interpolator) - { - this->m_FixedFeatureInterpolators[i] = interpolator; - this->Modified(); - } - } - -} // end SetFixedFeatureInterpolator() - - -/** - * ********************* GetFixedFeatureInterpolator **************************** - */ - -template -const typename ImageToImageMetricWithFeatures:: - FixedFeatureInterpolatorType * - ImageToImageMetricWithFeatures:: - GetFixedFeatureInterpolator(unsigned int i) const -{ - return this->m_FixedFeatureInterpolators[i].GetPointer(); -} // end GetFixedFeatureInterpolator() - -/** - * ********************* SetNumberOfMovingFeatureImages **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetNumberOfMovingFeatureImages(unsigned int arg) -{ - if (this->m_NumberOfMovingFeatureImages != arg) - { - this->m_MovingFeatureImages.resize(arg); - this->m_MovingFeatureInterpolators.resize(arg); - this->m_NumberOfMovingFeatureImages = arg; - this->Modified(); - } - -} // end SetNumberOfMovingFeatureImages() - - -/** - * ********************* SetMovingFeatureImage **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetMovingFeatureImage(unsigned int i, MovingFeatureImageType * im) -{ - if (i + 1 > this->m_NumberOfMovingFeatureImages) - { - this->m_MovingFeatureImages.resize(i + 1); - this->m_MovingFeatureImages[i] = im; - this->m_NumberOfMovingFeatureImages = i; - this->Modified(); - } - else - { - if (this->m_MovingFeatureImages[i] != im) - { - this->m_MovingFeatureImages[i] = im; - this->Modified(); - } - } - -} // end SetMovingFeatureImage() - - -/** - * ********************* GetMovingFeatureImage **************************** - */ - -template -const typename ImageToImageMetricWithFeatures:: - MovingFeatureImageType * - ImageToImageMetricWithFeatures:: - GetMovingFeatureImage(unsigned int i) const -{ - return this->m_MovingFeatureImages[i].GetPointer(); -} // end GetMovingFeatureImage() - -/** - * ********************* SetMovingFeatureInterpolator **************************** - */ - -template -void -ImageToImageMetricWithFeatures:: - SetMovingFeatureInterpolator(unsigned int i, MovingFeatureInterpolatorType * interpolator) -{ - if (i + 1 > this->m_NumberOfMovingFeatureImages) - { - this->m_MovingFeatureInterpolators.resize(i + 1); - this->m_MovingFeatureInterpolators[i] = interpolator; - this->m_NumberOfMovingFeatureImages = i; - this->Modified(); - } - else - { - if (this->m_MovingFeatureInterpolators[i] != interpolator) - { - this->m_MovingFeatureInterpolators[i] = interpolator; - this->Modified(); - } - } - -} // end SetMovingFeatureInterpolator() - - -/** - * ********************* GetMovingFeatureInterpolator **************************** - */ - -template -const typename ImageToImageMetricWithFeatures:: - MovingFeatureInterpolatorType * - ImageToImageMetricWithFeatures:: - GetMovingFeatureInterpolator(unsigned int i) const -{ - return this->m_MovingFeatureInterpolators[i].GetPointer(); -} // end GetMovingFeatureInterpolator() - -/** - * ****************** CheckForBSplineFeatureInterpolators ********************** - */ - -template -void -ImageToImageMetricWithFeatures:: - CheckForBSplineFeatureInterpolators() -{ - /** Check if the interpolators are of type BSplineInterpolateImageFunction. - * If so, we can make use of its EvaluateDerivatives method. - * Otherwise, an exception is thrown. - */ - this->m_FeatureInterpolatorsIsBSpline.resize(this->m_NumberOfMovingFeatureImages, false); - this->m_MovingFeatureBSplineInterpolators.resize(this->m_NumberOfMovingFeatureImages); - for (unsigned int i = 0; i < this->m_NumberOfMovingFeatureImages; ++i) - { - BSplineInterpolatorType * testPtr = - dynamic_cast(this->m_MovingFeatureInterpolators[i].GetPointer()); - - if (testPtr) - { - this->m_FeatureInterpolatorsIsBSpline[i] = true; - this->m_MovingFeatureBSplineInterpolators[i] = testPtr; - itkDebugMacro("Interpolator " << i << " is B-spline."); - } - else - { - itkDebugMacro("Interpolator " << i << " is NOT B-spline."); - itkExceptionMacro("Interpolator " << i << " is NOT B-spline."); - } - } // end for-loop - -} // end CheckForBSplineFeatureInterpolators() - - -/** - * ********************* PrintSelf **************************** - */ - -template -void -ImageToImageMetricWithFeatures::PrintSelf( - std::ostream & os, - Indent indent) const -{ - Superclass::PrintSelf(os, indent); - - os << indent << "NumberOfFixedFeatureImages: " << this->m_NumberOfFixedFeatureImages << std::endl; - os << indent << "NumberOfMovingFeatureImages: " << this->m_NumberOfMovingFeatureImages << std::endl; - - /** Print the feature image pointers. */ - for (unsigned int i = 0; i < this->m_NumberOfFixedFeatureImages; ++i) - { - os << indent << "FixedFeatureImages[" << i << "]: " << this->m_FixedFeatureImages[i].GetPointer() << std::endl; - } - for (unsigned int i = 0; i < this->m_NumberOfMovingFeatureImages; ++i) - { - os << indent << "MovingFeatureImages[" << i << "]: " << this->m_MovingFeatureImages[i].GetPointer() << std::endl; - } - - /** Print the feature interpolators pointers. */ - for (unsigned int i = 0; i < this->m_NumberOfFixedFeatureImages; ++i) - { - os << indent << "FixedFeatureInterpolators[" << i << "]: " << this->m_FixedFeatureInterpolators[i].GetPointer() - << std::endl; - } - for (unsigned int i = 0; i < this->m_NumberOfMovingFeatureImages; ++i) - { - os << indent << "MovingFeatureInterpolators[" << i << "]: " << this->m_MovingFeatureInterpolators[i].GetPointer() - << std::endl; - } - -} // end PrintSelf() - - -} // end namespace itk - -#endif // end #ifndef _itkImageToImageMetricWithFeatures_hxx