[vtkusers] vtkImageResample interpolation
Bruno Travençolo
bruno_travencolo at fastmail.fm
Thu Apr 14 16:38:30 EDT 2005
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.
More information about the vtkusers
mailing list