diff --git a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkPyramidRegistrationMethodHelper.h b/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkPyramidRegistrationMethodHelper.h index 7ca5fd8d5f..7790702c2b 100644 --- a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkPyramidRegistrationMethodHelper.h +++ b/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkPyramidRegistrationMethodHelper.h @@ -1,62 +1,95 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKPYRAMIDREGISTRATIONMETHODHELPER_H #define MITKPYRAMIDREGISTRATIONMETHODHELPER_H #include #include #include #include #include #include #include #include +#include + +#include "mitkImageAccessByItk.h" + +/** + * @brief Provides same functionality as \a AccessTwoImagesFixedDimensionByItk for a subset of types + * + * For now, the subset defined is only short and float. + */ +#define AccessTwoImagesFixedDimensionTypeSubsetByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension) \ +{ \ + const mitk::PixelType& pixelType1 = mitkImage1->GetPixelType(); \ + const mitk::PixelType& pixelType2 = mitkImage2->GetPixelType(); \ + const mitk::Image* constImage1 = mitkImage1; \ + const mitk::Image* constImage2 = mitkImage2; \ + mitk::Image* nonConstImage1 = const_cast(constImage1); \ + mitk::Image* nonConstImage2 = const_cast(constImage2); \ + nonConstImage1->Update(); \ + nonConstImage2->Update(); \ + _checkSpecificDimension(mitkImage1, (dimension)); \ + _checkSpecificDimension(mitkImage2, (dimension)); \ + _accessTwoImagesByItkForEach(itkImageTypeFunction, ((short, dimension))((float, dimension)), ((short, dimension))((float, dimension)) ) \ + { \ + std::string msg("Pixel type "); \ + msg.append(pixelType1.GetComponentTypeAsString() ); \ + msg.append(" or pixel type "); \ + msg.append(pixelType2.GetComponentTypeAsString() ); \ + msg.append(" is not in " MITK_PP_STRINGIZE(MITK_ACCESSBYITK_TYPES_DIMN_SEQ(dimension))); \ + throw mitk::AccessByItkException(msg); \ + } \ +} + /** * @brief The PyramidOptControlCommand class stears the step lenght of the * gradient descent optimizer in multi-scale registration methods */ template class PyramidOptControlCommand : public itk::Command { public: typedef itk::RegularStepGradientDescentOptimizer OptimizerType; itkNewMacro( PyramidOptControlCommand ) void Execute(itk::Object *caller, const itk::EventObject & /*event*/) { RegistrationType* registration = dynamic_cast< RegistrationType* >( caller ); if( registration->GetCurrentLevel() == 0 ) return; OptimizerType* optimizer = dynamic_cast< OptimizerType* >(registration->GetOptimizer()); optimizer->SetMaximumStepLength( optimizer->GetMaximumStepLength() * 0.25f ); optimizer->SetMinimumStepLength( optimizer->GetMinimumStepLength() * 0.1f ); } void Execute(const itk::Object * /*object*/, const itk::EventObject & /*event*/){} }; + #endif // MITKPYRAMIDREGISTRATIONMETHODHELPER_H