- {
- typedef itk::Image< unsigned char, Dimension > ImageMaskType;
- typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
- MaskReaderType::Pointer maskReader = MaskReaderType::New();
- maskReader->SetFileName(m_ArgsInfo.mask_arg);
-
- try
- {
- maskReader->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught while reading mask !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
- if (m_Verbose)std::cout <<"Mask was read..." <<std::endl;
-
- // Set the image to the spatialObject
- spatialObjectMask = MaskType::New();
- spatialObjectMask->SetImage( maskReader->GetOutput() );
- }
-
-
- // Samplingfactors
- InputImageType::SizeType samplingFactors;
- for (unsigned int i=0; i< Dimension; i++)
- {
- samplingFactors[i]= (int) ( input->GetSpacing()[i]/ filter->GetOutputSpacing()[i]);
- if (m_Verbose) std::cout<<"Setting sampling factor "<<i<<" to "<<samplingFactors[i]<<"..."<<std::endl;
- }
-
-
- // Set
- transform->SetSplineOrders(splineOrders);
- transform->SetMask(spatialObjectMask);
- transform->SetLUTSamplingFactors(samplingFactors);
- transform->SetCoefficientImage(input);
- filter->SetTransform(transform);
-
-
- // -----------------------------------------------
- // Update
- // -----------------------------------------------
- if (m_Verbose)std::cout<< "Converting the BSpline transform..."<<std::endl;
- try
- {
- filter->Update();
- }
- catch (itk::ExceptionObject)
- {
- std::cerr<<"Error: Exception thrown during execution convertion filter!"<<std::endl;
- }
-