- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template<class args_info_type>
- template <unsigned int Dimension, class PixelType>
- void
- InvertVFGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename OutputImageType::Pointer output;
- switch (m_ArgsInfo.type_arg)
- {
-
- // clitk filter
- case 0:
- {
- // Create the InvertVFFilter
- typedef clitk::InvertVFFilter<InputImageType,OutputImageType> FilterType;
- typename FilterType::Pointer filter =FilterType::New();
- filter->SetInput(input);
- filter->SetVerbose(m_Verbose);
- if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
- if (m_ArgsInfo.pad_given)
- {
- PixelType pad;
- if (m_ArgsInfo.pad_given != (pad.GetNumberOfComponents()) )
- pad.Fill(m_ArgsInfo.pad_arg[0]);
- else
- for(unsigned int i=0; i<Dimension; i++)
- pad[i]=m_ArgsInfo.pad_arg[i];
- }
- filter->SetThreadSafe(m_ArgsInfo.threadSafe_flag);
- filter->Update();
- output=filter->GetOutput();
-
- break;
- }
-
- case 1:
- {
- // Create the InverseDeformationFieldFilter
- typedef itk::InverseDeformationFieldImageFilter<InputImageType,OutputImageType> FilterType;
- typename FilterType::Pointer filter =FilterType::New();
- filter->SetInput(input);
- filter->SetOutputOrigin(input->GetOrigin());
- filter->SetOutputSpacing(input->GetSpacing());
- filter->SetSize(input->GetLargestPossibleRegion().GetSize());
- filter->SetSubsamplingFactor(m_ArgsInfo.sampling_arg);
- filter->Update();
- output=filter->GetOutput();
-
- break;
- }
-
- }
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-