[vtkusers] Image Shifts between Parallel Projection mode and Perspective mode

David Gobbi david.gobbi at gmail.com
Tue Sep 12 17:52:09 EDT 2017


If you're looking at a 2D slice that is positioned at the focal plane,
there should be no shift.

I tested this with the ImageSlicing.py example (in
Examples/ImageProcessing).  I used the following code when switching to
parallel projection:

        d = camera.GetDistance()
        a = camera.GetViewAngle()
        camera.SetParallelScale(d*math.tan(0.5*(a*math.pi/180)))
        camera.ParallelProjectionOn()
        window.Render()

And the following code when switching to perspective:

        d = camera.GetDistance()
        h = camera.GetParallelScale()
        camera.SetViewAngle(2.0*math.atan(h/d)*180/math.pi)
        camera.ParallelProjectionOff()
        window.Render()

There was no perceptible shift when switching, even with a full-screen
window zoomed way in.  IMHO if there is a shift, then either (a) the image
is not at the focal plane, or (b) there is a math error in your code, or
(c) there is a bug in VTK.

Volume rendering or any other rendering where objects aren't at the focal
plane is another matter, of course.

 - David



On Tue, Sep 12, 2017 at 2:50 PM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:

> Doug,
>
> We've seen this in ParaView too. The reason is that zoom is
> implemented totally differently when in perspective or parallel
> projection mode [1]. Thus the effect of zooming in one mode doesn't
> follow through to the other mode.
>
> Utkarsh
>
>
> [1] https://gitlab.kitware.com/vtk/vtk/blob/master/Rendering/
> Core/vtkCamera.cxx#L878
>
> On Tue, Sep 12, 2017 at 3:56 PM, Doug Hoppes <dhoppes at mbfbioscience.com>
> wrote:
> > Hi all,
> >
> >
> >
> >                 Got a question.  I’m using the function,
> > SetParallelProjection(true/false) to set the display between projection
> mode
> > and perspective mode.  I’m noticing that there is a shift in the image.
> I
> > was hoping that the image would stay the same.  I thought that it was in
> our
> > code but was able to reproduce this effect with a vtk example code.
> >
> >
> >
> >                 Any idea what’s going on?  The closer that I’m zoomed in
> on
> > my objects, the more the shift happens.
> >
> >
> >
> > Doug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170912/5e80691f/attachment.html>


More information about the vtkusers mailing list