[Insight-users] Dose resample filter support vector field?

Bill Lorensen bill.lorensen at gmail.com
Sun Feb 15 07:57:05 EST 2009


Try itkVectorResampleImageFilter.

Examples/Filtering/ResampleImageFilter9.cxx illustrates the class.

On Sat, Feb 14, 2009 at 4:11 PM, Hsiang-Chi Kuo <kuoxgx at gmail.com> wrote:
> Hi,
>
>  I am working on a deformable registration program with the diffeomorphic
>   Demons registration filter. Due to the memory issue, I have to apply the
>   region of interest filer to the input image such that I can run the
> program  and get the deform field. Then I tried to use resample image filter
> to
>   restore the size of the deform field back to the original size of the
> input image. First, the resample image  filter dose not allow me to set the
>   default pixel to zero. If I by pass the setting of the background to
> zero, it turn out the attached error message.
>   Dose the resample image filter support vector field? If not, any way I
> can solve my problem? Bellowed please also find part of my code.
>   Thanks and regards,
> Howard
>
> typedef itk::Image< VectorPixelType, Dimension >   DeformationFieldType;
>   typedef itk::ImageFileWriter< DeformationFieldType >  FieldWriterType;
>
>   typename FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
>   fieldWriter->SetFileName( args.outputFieldFile0.c_str() );
>
>   typedef
> itk::ResampleImageFilter<DeformationFieldType,DeformationFieldType>
> FilterType;
>   FilterType::Pointer resampleFilter = FilterType::New();
>
>   typedef itk::AffineTransform< double, Dimension >  TransformType;
>
>   TransformType::Pointer transform = TransformType::New();
>   resampleFilter->SetTransform( transform );
>
>   typedef itk::NearestNeighborInterpolateImageFunction<
>                        DeformationFieldType, double >  InterpolatorType;
>
>   InterpolatorType::Pointer interpolator = InterpolatorType::New();
>   resampleFilter->SetInterpolator( interpolator );
>
>   //resampleFilter->SetDefaultPixelValue( 0 );
>
>   typename ImageType::Pointer outputImage = 0;
>   outputImage = outputImageReader -> GetOutput();
>   resampleFilter->SetSize(
> outputImage->GetLargestPossibleRegion().GetSize() );
>   resampleFilter->SetInput( defField );
>   fieldWriter->SetInput( resampleFilter->GetOutput() );
>   fieldWriter->SetUseCompression( true );
>
>   try
>       {
>          fieldWriter->Update();
>       }
>       catch( itk::ExceptionObject& err )
>       {
>          std::cout << "Unexpected error." << std::endl;
>          std::cout << err << std::endl;
>          exit( EXIT_FAILURE );
>       }
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list