54 if (inputImage ==
nullptr)
56 itkGenericExceptionMacro(
"The specified input image should not be null!");
59 itk::SmartPointer<itk::DataObject> outputImage;
62 using ElxTypedef =
decltype(elxTypedef);
64 if constexpr (TInputImage::ImageDimension == ElxTypedef::MovingDimension)
66 using InternalImageType =
typename ElxTypedef::MovingImageType;
68 if (internalPixelTypeString == ElxTypedef::MovingPixelTypeString)
70 if constexpr (std::is_same_v<TInputImage, InternalImageType>)
72 outputImage = inputImage;
76 const auto castFilter = itk::CastImageFilter<TInputImage, InternalImageType>::New();
77 castFilter->SetInput(inputImage);
79 outputImage = castFilter->GetOutput();
87 if (outputImage ==
nullptr)
89 itkGenericExceptionMacro(
"Failed to cast to the specified internal pixel type \""
90 << internalPixelTypeString
91 <<
"\". It may need to be added to the CMake variable ELASTIX_IMAGE_"
92 << TInputImage::ImageDimension <<
"D_PIXELTYPES.");