[vtkusers] Problem with resizing an image

ochampao ochampao at hotmail.com
Wed Feb 28 18:11:02 EST 2018


Hello vtkUsers,

I am trying to resize an image (e.g. which is loaded from a .png file) so
that its dimensions match those of another image already loaded. The two
images are then displayed on top of each other on the screen. I have tried
two approaches, but none of them work and I can't figure out why. 

The first approach uses vtkImageResize. When using this approach the image
that I am trying to resize appears unchanged on the screen.

The second approach uses vtkImageReslice. When using this approach the image
is cropped rather than resized to match the dimensions of the first image
(the image to be resized has larger dimensions). So this approach works
partially.

Below I have included two code samples to demonstrate the two approaches I
have tried. What am I doing wrong in my code? Is there another more
appropriate way for resizing image data?

Thanks,
Panos.

Approach 1, using vtkImageResize:
======================
// image2 is to be resized using the dimensions of image1
vtkNew<vtkImageResize> resizeFilter;
resizeFilter->SetResizeMethodToOutputDimensions();
resizeFilter->SetOutputDimensions(image1_dims[0], image1_dims[1], 0);
resizeFilter->InterpolateOn();
resizeFilter->SetInputData(image2);
resizeFilter->Update();

Approach 2, using vtkImageReslice:
======================
// image2 is to be resized using the dimensions of image1
vtkNew<vtkImageReslice> imgReslice;
imgReslice->SetInputData(image2);
imgReslice->SetOutputExtent(0, image1_dims[0], 0, image1_dims[1], 0, 0);
imgReslice->SetOutputDimensionality(2);
imgReslice->SetInterpolationModeToCubic();
imgReslice->SetOutputOrigin(0, 0, 0);
imgReslice->AutoCropOutputOff();
//imgReslice->SetInformationInput(image1);  // same effect as specifying
extent/origin
imgReslice->Update();



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list