[vtkusers] rescaling an image with vtkimageReslice

skific_riteh skific at riteh.hr
Mon Jul 2 02:25:04 EDT 2012


I had tried to rescale an image with vtkImageReslice, and somehow lost 
three pixels in each direction.
As I understood, the resulting image should be 256*4 and 256*4 in size. 
However, the image is 256*4-3 in size in every direction. What am I 
doing wrong?
btw, when I apply the vtkImageResample with SetAxisMagnificationFactor 
fns in directions 0 and 1 with factor 4,
I get the same result as with the vtkImageReslice.
Now the code looks like this:
...
std::string path = "$VTK_DATA_ROOT/Data/masonry.bmp";
     vtkSmartPointer<vtkImageReader2Factory> readerFactory =
         vtkSmartPointer<vtkImageReader2Factory>::New();
     vtkSmartPointer<vtkImageReader2> imageReader = 
readerFactory->CreateImageReader2(path.c_str());
     imageReader->SetFileName(path.c_str());
     imageReader->SetDataExtent(0, 255, 0, 255, 0, 0);
     imageReader->SetDataSpacing(1, 1, 1);
     imageReader->SetDataOrigin(0, 0, 0);
     imageReader->UpdateWholeExtent();
vtkSmartPointer<vtkImageReslice> reslice1  = 
vtkSmartPointer<vtkImageReslice>::New();
reslice1->SetInputConnection(imageReader->GetOutput()->GetProducerPort());
     reslice1->SetOutputSpacing(0.25,0.25,1);
     reslice1->Update();
vtkSmartPointer<vtkBMPWriter> writer = vtkSmartPointer<vtkBMPWriter>::New();
     writer->SetFileName("output_reslice.bmp");
     writer->SetInput(reslice1->GetOutput());
     writer->Write();
...
thanx



More information about the vtkusers mailing list