[vtkusers] Linear interpolation as implemented by vtkImageReslice
David Gobbi
david.gobbi at gmail.com
Wed Sep 19 07:30:44 EDT 2007
Hi Luca,
To see how vtkImageReslice zooms an image by a factor of 2, you
should be doing something like this:
vtkPNGReader *reader = vtkPNGReader::New();
reader->SetFileName("myfile.png");
reader->SetDataSpacing(1.0, 1.0, 1.0); // tell VTK what pixel spacing to use
vtkImageReslice *reslice = vtkImageReslice::New();
reslice->SetInput(reader->GetOutput());
reslice->SetOutputSpacing(0.5, 0.5, 0.5); // resample with zoom factor of 2.0
If you write the output of this reslice to a file, you will see
exactly what you expect, i.e. a new pixel inserted between all
the old pixels in both the vertical and horizontal directions. So if
the original image size was 100x100, the new image will be
199x199 because 99 new pixels have been inserted in the
horizontal and vertical directions.
Since this is not what you are seeing, then there might be something
wrong with the way you are appying the zoom factor. If you can send
a few lines of code that show how you are using vtkImageReslice, that
would help me to fully answer your question.
Cheers,
David
On 9/19/07, Luca Pamparana <luca.pamparana at gmail.com> wrote:
> Hi everyone,
>
> I had asked this question a few days back but did not receive any help.
> Asking it again hoping someone would answer my query!
>
> Just trying to understand the linear interpolation algorithm as implemented
> in the vtkImageReslice class. I tried looking at the source code but it is
>
> really complicated and I could not understand much :(
>
> Anyway, I am zooming my image by a factor of 2. The image is a synthetic
> image which has a thick edge going along its diagonal (the value is changing
> from 0 to 255) and I am trying to look at how the values are interpolated in
> that region.
>
>
> One thing I noticed is that there are 2 pixels being inserted in the
> horizontal direction. So, I get the values 255, 191, 64 and 0 (255 and 0 are
> the old values and the two new values are being generated by taking a
> weighted average). Is this correct? I thought that if I zoom by a factor of
>
> 2.0 than one pixel should be inserted between successive pixels. I am not
> sure what happens at the edge pixels though.
>
> Also, what happens in the vertical direction? I cannot really figure out how
> this works...
>
>
> So if I have pixel values as follows:
>
> 255 0 1 2
> 0 255 0 1
>
> How is the lienar interpolation being done on a zoom of 2.0?
>
> I would really appreciate it if someone can clarify these doubts for me....
> I have spend a lot of time trying to understand this but have not yet been
> able to comprehend this implementation.
>
>
> Thanks,
>
> Luca
>
> _______________________________________________
> 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