-
-
- // -------------------------------------------
- // Spacing like DVF
- // -------------------------------------------
- if (m_ArgsInfo.spacing_arg == 0)
- {
- // Calculate the region
- typename DeformationFieldType::SizeType newSize;
- for (unsigned int i=0 ; i <Dimension; i++)
- newSize[i]=(unsigned int) (input->GetLargestPossibleRegion().GetSize()[i]*input->GetSpacing()[i]/deformationField->GetSpacing()[i]);
-
- // Get the interpolator
- typedef clitk::GenericVectorInterpolator<args_info_clitkWarpImage, DeformationFieldType, double> GenericInterpolatorType;
- typename GenericInterpolatorType::Pointer genericInterpolator=GenericInterpolatorType::New();
- genericInterpolator->SetArgsInfo(m_ArgsInfo);
-
- // Resample to match the extent of the input
- typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
- resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
- resampler->SetInput(deformationField);
- resampler->SetOutputSpacing(deformationField->GetSpacing());
- resampler->SetSize(newSize);
- resampler->SetOutputOrigin(input->GetOrigin());
- resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
-
- // Update
- if (m_Verbose) std::cout<< "Resampling the VF..." <<std::endl;
- try {
- resampler->Update();
- }
- catch( itk::ExceptionObject & excp ) {
- std::cerr << "Problem resampling the input vector field file" << std::endl;
- std::cerr << excp << std::endl;
- return;
- }
- deformationField= resampler->GetOutput();
-
- }
-
- // -------------------------------------------
- // Spacing like input
- // -------------------------------------------
- else
- {
- // Get size
- typename DeformationFieldType::SizeType newSize;
- for (unsigned int i=0 ; i <Dimension; i++)
- newSize[i]=input->GetLargestPossibleRegion().GetSize()[i];
-
- // Resample to match the extent of the input
- typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
- resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
- resampler->SetInput(deformationField);
- resampler->SetOutputSpacing(input->GetSpacing());
- resampler->SetSize(newSize);
- resampler->SetOutputOrigin(input->GetOrigin());
- resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
-
- // Update
- if (m_Verbose) std::cout<< "Resampling the VF..." <<std::endl;
- try {
- resampler->Update();
- }
- catch( itk::ExceptionObject & excp ) {
- std::cerr << "Problem resampling the input vector field file" << std::endl;
- std::cerr << excp << std::endl;
- return;
- }
- deformationField= resampler->GetOutput();
- }
-
-
- // -------------------------------------------
- // Forward Warp
- // -------------------------------------------
- typename itk::ImageToImageFilter<InputImageType, InputImageType>::Pointer warpFilter;
- if (m_ArgsInfo.forward_flag)
- {
- //Forward warping: always linear
- typedef clitk::ForwardWarpImageFilter<InputImageType, InputImageType, DeformationFieldType> ForwardWarpFilterType;
- typename ForwardWarpFilterType::Pointer forwardWarpFilter= ForwardWarpFilterType::New();
- forwardWarpFilter->SetDeformationField( deformationField );
- forwardWarpFilter->SetEdgePaddingValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
- warpFilter=forwardWarpFilter;
- }
-
- // -------------------------------------------
- // Backward Warp
- // -------------------------------------------
- else
- {
- // Get the interpolator
- typedef clitk::GenericInterpolator<args_info_clitkWarpImage, InputImageType, double> GenericInterpolatorType;
- typename GenericInterpolatorType::Pointer genericInterpolator=GenericInterpolatorType::New();
- genericInterpolator->SetArgsInfo(m_ArgsInfo);
-
- //Backward mapping
- typedef itk::WarpImageFilter<InputImageType, InputImageType, DeformationFieldType> BackwardWarpFilterType;
- typename BackwardWarpFilterType::Pointer backwardWarpFilter= BackwardWarpFilterType::New();
- backwardWarpFilter->SetDeformationField( deformationField );
- backwardWarpFilter->SetEdgePaddingValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
- backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() );
- backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );
- backwardWarpFilter->SetOutputSize( deformationField->GetLargestPossibleRegion().GetSize() );
- typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
- resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
- backwardWarpFilter->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
- warpFilter=backwardWarpFilter;
- }
-
-
- // -------------------------------------------