diff --git a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py new file mode 100644 index 00000000..0a62d1b9 --- /dev/null +++ b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +# 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 +# +# 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. + +import os +from urllib.request import urlretrieve + +import itk + +# Verify wrapping succeeded +assert 'MultiResolutionFixedBlockRadiusCalculator' in dir(itk.Ultrasound) + +# Get image input for registration +FIXED_IMAGE_PATH = 'Input/rf_pre15.mha' +MOVING_IMAGE_PATH = 'Input/rf_post15.mha' + +if not os.path.exists(FIXED_IMAGE_PATH): + url = 'https://data.kitware.com/api/v1/file/58ee3b778d777f16d095fd8a/download' + urlretrieve(url, FIXED_IMAGE_PATH) + +if not os.path.exists(MOVING_IMAGE_PATH): + url = 'https://data.kitware.com/api/v1/file/58ee3b758d777f16d095fd87/download' + urlretrieve(url, MOVING_IMAGE_PATH) + +fixed_image = itk.imread(FIXED_IMAGE_PATH, itk.F) +moving_image = itk.imread(MOVING_IMAGE_PATH, itk.F) + +dimension = fixed_image.GetImageDimension() +displacement_image_type = itk.Image[itk.Vector[itk.F,dimension],dimension] + +block_radius_calculator = itk.Ultrasound.MultiResolutionFixedBlockRadiusCalculator[type(fixed_image)].New() +block_radius_calculator.SetRadius([12,4]) + +# Create schedule for iterative registration +search_region_source = itk.Ultrasound.MultiResolutionFixedSearchRegionImageSource[type(fixed_image), + type(fixed_image), + displacement_image_type].New() +pyramid_schedule = itk.Array2D[itk.UI]() +pyramid_schedule.SetSize(3,2) +pyramid_schedule.SetElement(0,0,3) +pyramid_schedule.SetElement(0,1,2) +pyramid_schedule.SetElement(1,0,2) +pyramid_schedule.SetElement(1,1,1) +pyramid_schedule.SetElement(2,0,1) +pyramid_schedule.SetElement(2,1,1) + +search_region_source.SetPyramidSchedule(pyramid_schedule) +search_region_source.SetSearchRegionRadiusSchedule([50,6]) +search_region_source.SetOverlapSchedule(1.0) + +metric_image_filter = itk.Ultrasound.NormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter[type(fixed_image), + type(fixed_image), + type(fixed_image)].New() + +level_registration_method = itk.Ultrasound.BlockMatchingImageRegistrationMethod[type(fixed_image), + type(fixed_image), + type(fixed_image), + displacement_image_type, + itk.F].New() +level_registration_method.SetMetricImageFilter(metric_image_filter) + +# Set up the multi-resolution registration object +multi_res_registration_method = itk.Ultrasound.BlockMatchingMultiResolutionImageRegistrationMethod[type(fixed_image), + type(fixed_image), + type(fixed_image), + displacement_image_type, + itk.F].New() +multi_res_registration_method.SetFixedImage(fixed_image) +multi_res_registration_method.SetMovingImage(moving_image) +multi_res_registration_method.SetBlockRadiusCalculator(block_radius_calculator) +multi_res_registration_method.SetSearchRegionImageSource(search_region_source) +multi_res_registration_method.SetSchedules(pyramid_schedule, pyramid_schedule) +multi_res_registration_method.SetImageRegistrationMethod(level_registration_method) + +# Run the actual registration +multi_res_registration_method.Update() + +# Write out results +itk.imwrite(multi_res_registration_method.GetOutput(), 'Output/rf_post15_registered.mha') diff --git a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx index 165393a7..445bbdd0 100644 --- a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx +++ b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx @@ -342,8 +342,8 @@ BayesianRegularizationDisplacementCalculator:: typename FaceCalculatorType::FaceListType::iterator fit; MetricImageImagePointerType tempMetricImageImagePtr; - MetricImagePointerType postImage; - MetricImagePointerType priorImage; + //MetricImagePointerType postImage; + //MetricImagePointerType priorImage; m_CurrentIteration = 0; // Hack to make the SplitRequestedRegion method operate on the face list // regions; @@ -425,14 +425,14 @@ BayesianRegularizationDisplacementCalculator:: { priorImage = priorImageImageIt.GetPrevious(direction); // If we are inside the boundary. - if (priorImage.GetPointer() != nullptr) + if (priorImage != nullptr) { shift.Fill(0.0); shift[direction] = -1 * spacing[direction]; this->ImpartLikelihood(postImage, priorImage, direction, shift); } priorImage = priorImageImageIt.GetNext(direction); - if (priorImage.GetPointer() != nullptr) + if (priorImage != nullptr) { shift.Fill(0.0); shift[direction] = spacing[direction]; diff --git a/include/itkBlockMatchingDisplacementPipeline.h b/include/itkBlockMatchingDisplacementPipeline.h index c640f114..4a3af245 100644 --- a/include/itkBlockMatchingDisplacementPipeline.h +++ b/include/itkBlockMatchingDisplacementPipeline.h @@ -129,7 +129,7 @@ class ITK_TEMPLATE_EXPORT DisplacementPipeline /** The registration method. */ using LevelRegistrationMethodType = BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; /** Interpolation classes. */ using ParabolicInterpolatorType = @@ -174,7 +174,7 @@ class ITK_TEMPLATE_EXPORT DisplacementPipeline BlockMatching::BayesianRegularizationDisplacementCalculator; /** Multi-resolution registration method. */ - using RegistrationMethodType = BlockMatching::MultiResolutionImageRegistrationMethod -class ITK_TEMPLATE_EXPORT ImageRegistrationMethod +class ITK_TEMPLATE_EXPORT BlockMatchingImageRegistrationMethod : public ImageToImageFilter, TDisplacementImage> { public: - ITK_DISALLOW_COPY_AND_ASSIGN(ImageRegistrationMethod); + ITK_DISALLOW_COPY_AND_ASSIGN(BlockMatchingImageRegistrationMethod); /** ImageDimension enumeration. */ itkStaticConstMacro(ImageDimension, unsigned int, TDisplacementImage::ImageDimension); @@ -92,7 +92,7 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod using SearchRegionImageType = Image; /** Standard class type alias. */ - using Self = ImageRegistrationMethod; + using Self = BlockMatchingImageRegistrationMethod; using Superclass = ImageToImageFilter; using Pointer = SmartPointer; using ConstPointer = SmartPointer; @@ -101,7 +101,7 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(ImageRegistrationMethod, ImageSource); + itkTypeMacro(BlockMatchingImageRegistrationMethod, ImageSource); /** Type of the point use for determing the location in the fixed image of a * block's center. */ @@ -188,8 +188,8 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod protected: - ImageRegistrationMethod(); - virtual ~ImageRegistrationMethod() {} + BlockMatchingImageRegistrationMethod(); + virtual ~BlockMatchingImageRegistrationMethod() {} void GenerateOutputInformation() override; diff --git a/include/itkBlockMatchingImageRegistrationMethod.hxx b/include/itkBlockMatchingImageRegistrationMethod.hxx index 394c1c33..2e96d136 100644 --- a/include/itkBlockMatchingImageRegistrationMethod.hxx +++ b/include/itkBlockMatchingImageRegistrationMethod.hxx @@ -36,8 +36,8 @@ template -ImageRegistrationMethod:: - ImageRegistrationMethod() +BlockMatchingImageRegistrationMethod:: + BlockMatchingImageRegistrationMethod() : m_UseStreaming(false) { m_FixedImage = nullptr; @@ -55,7 +55,7 @@ template void -ImageRegistrationMethod::SetFixedImage( +BlockMatchingImageRegistrationMethod::SetFixedImage( FixedImageType * fixedImage) { if (this->m_FixedImage.GetPointer() != fixedImage) @@ -72,7 +72,7 @@ template void -ImageRegistrationMethod::SetMovingImage( +BlockMatchingImageRegistrationMethod::SetMovingImage( MovingImageType * movingImage) { if (this->m_MovingImage.GetPointer() != movingImage) @@ -89,7 +89,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: GenerateOutputInformation() { Superclass::GenerateOutputInformation(); @@ -109,7 +109,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: GenerateInputRequestedRegion() { Superclass::GenerateInputRequestedRegion(); @@ -132,7 +132,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: EnlargeOutputRequestedRegion(DataObject * data) { this->m_MetricImageToDisplacementCalculator->ModifyEnlargeOutputRequestedRegion(data); @@ -145,7 +145,7 @@ template void -ImageRegistrationMethod::GenerateData() +BlockMatchingImageRegistrationMethod::GenerateData() { const SearchRegionImageType * input = this->GetInput(); @@ -212,7 +212,7 @@ template void -ImageRegistrationMethod::Initialize() +BlockMatchingImageRegistrationMethod::Initialize() { if (!m_FixedImage) { diff --git a/include/itkBlockMatchingMetricImageFilter.h b/include/itkBlockMatchingMetricImageFilter.h index d2ca8271..789226fa 100644 --- a/include/itkBlockMatchingMetricImageFilter.h +++ b/include/itkBlockMatchingMetricImageFilter.h @@ -31,7 +31,7 @@ namespace BlockMatching * region. * * This class is intended to be used internally by - * itk::BlockMatching::ImageRegistrationMethod and its ilk. + * itk::BlockMatching::BlockMatchingImageRegistrationMethod and its ilk. * * There are two inputs to this image, the Fixed Image, and the Moving Image. * A block or kernel from the FixedImage is specified with SetFixedRegion(). diff --git a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h index 6f4516b8..9e70f97a 100644 --- a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h +++ b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h @@ -32,7 +32,7 @@ namespace BlockMatching * * \brief Calculates the displacement of a block from the MetricImage(s). * - * This class tightly integrates with BlockMatching::ImageRegistrationMethod. + * This class tightly integrates with BlockMatching::BlockMatchingImageRegistrationMethod. * It is the responsibility of this class to calculate the displacement given * MetricImage(s) in a block matching registration method. * @@ -47,7 +47,7 @@ namespace BlockMatching * * Caching of the MetricImage can be enabled by SetCacheMetricImageOn(); * - * The behavior of the associated BlockMatching::ImageRegistrationMethod + * The behavior of the associated BlockMatching::BlockMatchingImageRegistrationMethod * GenerateInputRequestedRegion() and EnlargeOutputRequestedRegion() with * ModifyGenerateInputRequestedRegion() and * ModifyEnlargeOutputRequestedRegion(). @@ -71,7 +71,7 @@ class ITK_TEMPLATE_EXPORT MetricImageToDisplacementCalculator : public Object /** Type of the metric image (input pixels). */ using MetricImageType = TMetricImage; - using MetricImagePointerType = typename MetricImageType::Pointer; + using MetricImagePointerType = MetricImageType*; // TODO ::Pointer using IndexType = typename MetricImageType::IndexType; /** Type of the displacement image (output). */ @@ -134,13 +134,13 @@ class ITK_TEMPLATE_EXPORT MetricImageToDisplacementCalculator : public Object virtual void Compute() = 0; - /** Modify the associated BlockMatching::ImageRegistrationMethod's + /** Modify the associated BlockMatching::BlockMatchingImageRegistrationMethod's * GenerateInputRequestedRegion(). */ virtual void ModifyGenerateInputRequestedRegion(RegionType & region) {} - /** Modify the associated BlockMatching::ImageRegistrationMethod's + /** Modify the associated BlockMatching::BlockMatchingImageRegistrationMethod's * EnlargeOutputRequestedRegion(). */ virtual void ModifyEnlargeOutputRequestedRegion(DataObject * data) diff --git a/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h b/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h index 3363c58a..c2b1946e 100644 --- a/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h +++ b/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h @@ -29,7 +29,7 @@ namespace BlockMatching /** \class MultiResolutionBlockRadiusCalculator * * \brief Base class calculate the fixed image matching kernel radius for each level in a - * BlockMatching::MultiResolutionImageRegistrationMethod. + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod. * * This must be able to produce the fixed image block radius for every level of * the MultiResolutionPyramidImage filter. @@ -74,7 +74,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionBlockRadiusCalculator : public Object itkGetConstReferenceMacro(PyramidSchedule, ScheduleType); /** Set/Get the Fixed image. The fixed image is set during the - * BlockMatching::MultiResolutionImageRegistrationMethod and is available for + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod and is available for * child classes if the choose to use it. */ itkSetConstObjectMacro(FixedImage, FixedImageType); itkGetConstObjectMacro(FixedImage, FixedImageType); diff --git a/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h b/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h index f5f78aaf..295a4266 100644 --- a/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h +++ b/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h @@ -30,7 +30,7 @@ namespace BlockMatching * \brief A fixed radius is used for every level. * * This class generates the fixed image matching kernel radius in a - * BlockMatching::MultiResolutionImageRegistrationMethod. A fixed block radius + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod. A fixed block radius * is used, which means the size of the block in physical coordinates then * scales with the pyramid schedule. * diff --git a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h index 2c10c05e..9a2ebebd 100644 --- a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h +++ b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h @@ -30,7 +30,7 @@ namespace itk namespace BlockMatching { -/** \class MultiResolutionImageRegistrationMethod +/** \class BlockMatchingMultiResolutionImageRegistrationMethod * * \brief Base class for multi-resolution image registration methods in the * BlockMatching set of tools. @@ -42,7 +42,7 @@ namespace BlockMatching * The SetNumberOfLevels() or SetSchedule() is used to set up the * MultiResolutionPyramidImageFilter. * - * \sa ImageRegistrationMethod + * \sa BlockMatchingImageRegistrationMethod * * \ingroup RegistrationFilters * \ingroup Ultrasound @@ -52,10 +52,10 @@ template -class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageSource +class ITK_TEMPLATE_EXPORT BlockMatchingMultiResolutionImageRegistrationMethod : public ImageSource { public: - ITK_DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageRegistrationMethod); + ITK_DISALLOW_COPY_AND_ASSIGN(BlockMatchingMultiResolutionImageRegistrationMethod); /** ImageDimension enumeration. */ itkStaticConstMacro(ImageDimension, unsigned int, TDisplacementImage::ImageDimension); @@ -91,7 +91,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS using SearchRegionImageType = Image; /** Standard class type alias. */ - using Self = MultiResolutionImageRegistrationMethod; + using Self = BlockMatchingMultiResolutionImageRegistrationMethod; using Superclass = ImageSource; using Pointer = SmartPointer; using ConstPointer = SmartPointer; @@ -100,7 +100,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(MultiResolutionImageRegistrationMethod, ImageSource); + itkTypeMacro(BlockMatchingMultiResolutionImageRegistrationMethod, ImageSource); /** Type of the Fixed image multiresolution pyramid. */ using FixedImagePyramidType = MultiResolutionPyramidImageFilter; @@ -115,7 +115,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS /** Type of the registration method used at every level. */ using ImageRegistrationMethodType = typename BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; using ImageRegistrationMethodPointer = typename ImageRegistrationMethodType::Pointer; /** Type of the class to calculate the fixed image matching kernel block @@ -166,7 +166,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS ModifiedTimeType GetMTime() const override; - /** BlockMatching::ImageRegistrationMethod used to register each image at + /** BlockMatching::BlockMatchingImageRegistrationMethod used to register each image at * every level. */ itkSetObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType); itkGetModifiableObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType); @@ -181,8 +181,8 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS itkGetConstObjectMacro(SearchRegionImageSource, SearchRegionImageSourceType); protected: - MultiResolutionImageRegistrationMethod(); - virtual ~MultiResolutionImageRegistrationMethod(){}; + BlockMatchingMultiResolutionImageRegistrationMethod(); + virtual ~BlockMatchingMultiResolutionImageRegistrationMethod(){}; /** The size and spacing of the search region image at the lowest level is * used to generate the information for the output image. */ diff --git a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx index 1e4abdff..5411d868 100644 --- a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx +++ b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx @@ -33,8 +33,8 @@ template -MultiResolutionImageRegistrationMethod:: - MultiResolutionImageRegistrationMethod() +BlockMatchingMultiResolutionImageRegistrationMethod:: + BlockMatchingMultiResolutionImageRegistrationMethod() : m_FixedImage(nullptr) , m_MovingImage(nullptr) , m_NumberOfLevels(1) @@ -57,7 +57,7 @@ template ModifiedTimeType -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GetMTime() const { unsigned long mtime = Superclass::GetMTime(); @@ -85,7 +85,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: StopRegistration(void) { m_Stop = true; @@ -98,7 +98,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: Initialize() { // Sanity checks @@ -122,7 +122,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: SetSchedules(const ScheduleType & fixedImagePyramidSchedule, const ScheduleType & movingImagePyramidSchedule) { if (m_NumberOfLevelsSpecified) @@ -155,7 +155,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: SetNumberOfLevels(unsigned long numberOfLevels) { if (m_ScheduleSpecified) @@ -176,7 +176,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GenerateOutputInformation() { if (!m_FixedImage) @@ -215,7 +215,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PreparePyramids() { // Sanity checks @@ -259,7 +259,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PrepareBlockRadiusCalculator() { // Sanity checks @@ -279,7 +279,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PrepareSearchRegionImageSource() { // Sanity checks @@ -299,7 +299,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GenerateData() { m_Stop = false; diff --git a/include/itkBlockMatchingMultiResolutionIterationCommand.h b/include/itkBlockMatchingMultiResolutionIterationCommand.h index fa44f3f3..29c2b622 100644 --- a/include/itkBlockMatchingMultiResolutionIterationCommand.h +++ b/include/itkBlockMatchingMultiResolutionIterationCommand.h @@ -31,7 +31,7 @@ namespace BlockMatching * \class MultiResolutionIterationCommand * * \brief This is a base class for classes that want to observe/adjust a - * BlockMatching::MultiResolutionImageRegistrationMethod at every iteration. + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod at every iteration. * * \ingroup Ultrasound * */ diff --git a/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h b/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h index 4c558b3b..3808b2c9 100644 --- a/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h +++ b/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h @@ -35,7 +35,7 @@ template -class MultiResolutionImageRegistrationMethod; +class BlockMatchingMultiResolutionImageRegistrationMethod; /** \class MultiResolutionSearchRegionImageSource @@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionSearchRegionImageSource typename TMetricImage, typename TDisplacementImageF, typename TCoordRep> - friend class MultiResolutionImageRegistrationMethod; + friend class BlockMatchingMultiResolutionImageRegistrationMethod; itkGetConstObjectMacro(PreviousDisplacements, DisplacementImageType); diff --git a/include/itkBlockMatchingSearchRegionImageInitializer.h b/include/itkBlockMatchingSearchRegionImageInitializer.h index 8e4bb628..b93e6b3e 100644 --- a/include/itkBlockMatchingSearchRegionImageInitializer.h +++ b/include/itkBlockMatchingSearchRegionImageInitializer.h @@ -28,10 +28,10 @@ namespace BlockMatching /** \class SearchRegionImageInitializer * * \brief Creates a SearchRegionImage for input into a - * BlockMatching::ImageRegistrationMethod. + * BlockMatching::BlockMatchingImageRegistrationMethod. * * This creates a SearchRegionImage for input into the - * BlockMatching::ImageRegistrationMethod. The search regions are centered + * BlockMatching::BlockMatchingImageRegistrationMethod. The search regions are centered * around the fixed image blocks and evenly spaced. Overlap between blocks may * be set with SetOverlap(). The input fixed image, fixed image block radius, * moving image, and search region radius must be set. diff --git a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx index 7c909908..631c0f25 100644 --- a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx +++ b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx @@ -74,7 +74,7 @@ itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest(int argc, char // The image registration method. using RegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; RegistrationMethodType::Pointer registrationMethod = RegistrationMethodType::New(); registrationMethod->SetFixedImage(fixedReader->GetOutput()); registrationMethod->SetMovingImage(movingReader->GetOutput()); @@ -98,7 +98,9 @@ itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest(int argc, char strainSigma[1] = 0.04; regularizer->SetStrainSigma(strainSigma); regularizer->SetMaximumIterations(3); + //regularizer->SetCacheMetricImage(true); registrationMethod->SetMetricImageToDisplacementCalculator(regularizer); + registrationMethod->Update(); // Break the displacement vector image into components. using TensorComponentsFilterType = itk::SplitComponentsImageFilter; diff --git a/test/itkBlockMatchingImageRegistrationMethodTest.cxx b/test/itkBlockMatchingImageRegistrationMethodTest.cxx index ef956b9a..603fc676 100644 --- a/test/itkBlockMatchingImageRegistrationMethodTest.cxx +++ b/test/itkBlockMatchingImageRegistrationMethodTest.cxx @@ -67,7 +67,7 @@ itkBlockMatchingImageRegistrationMethodTest(int argc, char * argv[]) searchRegions->SetSearchRegionRadius(searchRadius); using RegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; RegistrationMethodType::Pointer registrationMethod = RegistrationMethodType::New(); registrationMethod->SetFixedImage(fixedReader->GetOutput()); registrationMethod->SetMovingImage(movingReader->GetOutput()); diff --git a/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx b/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx index cbcd3e1f..09e3a4a3 100644 --- a/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx +++ b/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx @@ -85,11 +85,11 @@ itkBlockMatchingMultiResolutionImageRegistrationMethodTest(int argc, char * argv MetricImageFilterType::Pointer metricImageFilter = MetricImageFilterType::New(); using LevelRegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; LevelRegistrationMethodType::Pointer levelRegistrationMethod = LevelRegistrationMethodType::New(); levelRegistrationMethod->SetMetricImageFilter(metricImageFilter); - using RegistrationMethodType = itk::BlockMatching::MultiResolutionImageRegistrationMethod, itk::Image<${ITKT_V${ITKM_${t}}${d}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap new file mode 100644 index 00000000..c65eec25 --- /dev/null +++ b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap @@ -0,0 +1,35 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkPoint.h") +itk_wrap_include("itkImage.h") + +# Wrap for member types +UNIQUE(real_types "${WRAP_ITK_REAL};D") +itk_wrap_class("itk::Image" POINTER) + foreach(t ${real_types}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("P${ITKM_${t}}${d}${d}" + "itk::Point<${ITKT_${t}}, ${d}>, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::Image" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}PTR${d}" + "itk::Image<${ITKT_${t}}, ${d}> *, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingMetricImageToDisplacementCalculator.h") +itk_wrap_class("itk::BlockMatching::MetricImageToDisplacementCalculator" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(t2 ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_V${t2}${d}}${d}" + "${ITKT_I${ITKM_${t}}${d}}, ${ITKT_I${ITKM_V${t2}${d}}${d}}") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap b/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap new file mode 100644 index 00000000..5a90a30f --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap @@ -0,0 +1,20 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkImage.h") + +itk_wrap_include("itkBlockMatchingMultiResolutionBlockRadiusCalculator.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionBlockRadiusCalculator" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionFixedBlockRadiusCalculator" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap b/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap new file mode 100644 index 00000000..23ae8089 --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap @@ -0,0 +1,46 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) + +itk_wrap_include("itkVector.h") +itk_wrap_include("itkImage.h") +itk_wrap_include("itkImageRegion.h") + +# Wrap for class template +itk_wrap_include("itkImageRegion.h") +itk_wrap_class("itk::Image" POINTER) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IR${d}${d}" "itk::ImageRegion<${d}>, ${d}") + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkImageSource.h") +itk_wrap_class("itk::ImageSource" POINTER) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IIR${d}${d}" "itk::Image,${d}>") + endforeach() +itk_end_wrap_class() + +# Wrap class hierarchy +itk_wrap_include("itkBlockMatchingMultiResolutionSearchRegionImageSource.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionSearchRegionImageSource" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_${t}}${d}I${ITKM_${vt}${d}}${d}" + "itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${vt}${d}},${d}>") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() + +# Wrap class +itk_wrap_include("itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionFixedSearchRegionImageSource" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_${t}}${d}I${ITKM_${vt}${d}}${d}" + "itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${vt}${d}},${d}>") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap new file mode 100644 index 00000000..7b0ada9d --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap @@ -0,0 +1,43 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkPoint.h") +itk_wrap_include("itkSmartPointer.h") +itk_wrap_include("itkImage.h") +itk_wrap_include("itkImageRegion.h") + +# Wrap class hierarchy +itk_wrap_include("itkImageToImageFilter.h") +itk_wrap_class("itk::ImageToImageFilter" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IIR${d}${d}I${ITKM_V${t}${d}}${d}" + "itk::Image,${d}>, itk::Image<${ITKT_V${t}${d}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingImageRegistrationMethod.h") +itk_wrap_class("itk::BlockMatching::BlockMatchingImageRegistrationMethod" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + set(img_m "I${ITKM_${t}}${d}") + set(img_t "itk::Image<${ITKT_${t}}, ${d}>") + itk_wrap_template("${img_m}${img_m}${img_m}I${ITKM_${vt}${d}}${d}" + "${img_t}, ${img_t}, ${img_t}, itk::Image<${ITKT_${vt}${d}},${d}>, ${ITKT_${t}}") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() + +# Wrap target class +itk_wrap_include("itkBlockMatchingMultiResolutionImageRegistrationMethod.h") +itk_wrap_class("itk::BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + set(img_m "I${ITKM_${t}}${d}") + set(img_t "itk::Image<${ITKT_${t}}, ${d}>") + itk_wrap_template("${img_m}${img_m}${img_m}I${ITKM_${vt}${d}}${d}" + "${img_t}, ${img_t}, ${img_t}, itk::Image<${ITKT_V${t}${d}},${d}>, ${ITKT_${t}}") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap b/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap new file mode 100644 index 00000000..4bad8c4a --- /dev/null +++ b/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap @@ -0,0 +1,16 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) + +itk_wrap_include("itkBlockMatchingMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::MetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingNormalizedCrossCorrelationMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::NormalizedCrossCorrelationMetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::NormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class()