[vtkusers] vtkImageResample interpolation

David Gobbi dgobbi at atamai.com
Thu Apr 14 17:07:34 EDT 2005


Hi Bruno,

This is bug with VTK 4.4, is that the version that you are using?

There are a few possible fixes:
1) call SetInterpolationModeToCubic(), since cubic interpolation doesn't 
exhibit the bug
2) download a patched copy of vtkImageReslice.cxx (the base class to 
vtkImageResample) from here:
   
http://public.kitware.com/cgi-bin/viewcvs.cgi/Imaging/vtkImageReslice.cxx?only_with_tag=release-4-4
3) switch to either VTK 4.2 or 4.5, whichever is more convenient

 - David

Bruno Travençolo wrote:

> Hi, All,
>
> I have some doubt about "vtkImageResample". Why the linear 
> interpolation doesn't work with float numbers. Look these examples:
>
> My volume:
> 0 255 0
>
> After vtkImageResample with Magnification Factor = 5  on 'x' axis:
> 0 51 102 153 204 255 204 153 102 51 0
>
> It's OK. But if my volume is composed by a number with decimals (1.1), 
> like this:
>
> 0 1.1 0
>
> After the interpolation I get:
> 0 0 0 1 1 1 1 1 0 0 0
>
> All the interpolated number are equal to 1. I  expected that the 
> result would be an linear interpolation between 0 and 1.1.
> Does anyone know why it isn't?
>
> My test code:
>
>   vtkDoubleArray *points = vtkDoubleArray::New();
>  points->SetNumberOfTuples(3);
>  points->SetTuple1(0,0);
> //  points->SetTuple1(1,255);
>  points->SetTuple1(1,1.1);
>  points->SetTuple1(2,0);
>
>  vtkImageData *vol = vtkImageData::New();
>  vol->SetDimensions(3,1,1);
>  vol->GetPointData()->SetScalars(points);
>  vol->Update();
>
>  double factor[3];
>  factor[0] = 5;
>  factor[1] = 1;
>  factor[2] = 1;
>  int InterpolationMode = VTK_RESLICE_LINEAR;
>
>  vtkImageResample *resample = vtkImageResample::New();
>  resample->SetInput(vol);
>  resample->SetAxisMagnificationFactor(0,factor[0]);
>  resample->SetAxisMagnificationFactor(1,factor[1]);
>  resample->SetAxisMagnificationFactor(2,factor[2]);
>  resample->SetInterpolationMode(InterpolationMode);
>  resample->Update();
>
>  vtkStructuredPointsWriter *write = vtkStructuredPointsWriter::New();
>  write->SetInput(resample->GetOutput());
>  write->SetFileName("teste.vtk");
>  write->Write();
>
> thanks,
> Bruno.
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list