[vtkusers] question about "ImageSlicing.cxx"

David Gobbi david.gobbi at gmail.com
Mon Nov 10 16:46:13 EST 2008


Hi Stephane,

The black borders that you see in this example are actually the
background in the renderer.  If you add
"renderer->SetBackground(1.0,0.0,0.0);" to the example, then you will
see the black bars turn to red.

In other words, it isn't vtkImageReslice that is adding these borders.
 These borders are present because the RenderWindow is square, and
vtkImageReslice has no control over the window size.

So what you need to do is call window->SetSize() to set the size of
the window to the size of your image.  You can call Update() on
ImageReslice and get the size of its output, so that you know what
size to make the window.

Even after you do this, though, you will still have to do one more
thing.  By default, the zoom factor for camera is not 1.0.  You will
have to call add code like the following:

  vtkCamera *camera = renderer->GetActiveCamera();
  camera->SetViewAngle(2.0*atan(0.5*height_of_image/camera_distance));

Alternatively, you can switch to parallel projections, which makes the
math easier but I'm not sure if the VTK interactors all work properly
in parallel mode:

  camera->ParallelProjectionOn();
  camera->SetParallelScale(height_of_image);

I hope this is what you were looking for,

    David











On Mon, Nov 10, 2008 at 9:38 AM, Stéphane CALANDE <scalande at gmail.com> wrote:
> Hi,
>
>
> I'm trying "ImageSlicing.cxx" to display an "coronal" slice from a volume
> (multiple axial slices).
>
> It works well, but there is just a problem.
>
>
> Information about my axial slices :
>
> SIZE : 512 x 512
> SPACING : (1,17188 ; 1,17188)
>
> "REAL" SIZE = 60 cm x 60 cm
>
>
> Information about the coronal slices that SHOULD be created
>
> SIZE : 512 x 55
> SPACING : (1,17188 ; 5)
>
> "REAL" SIZE = 60 cm x 27.5 cm
>
>
> But the problem is that the image created by "ImageSlicing" has the shape of
> a square.
> I mean it has the same shape than the axial images.
>
> The representation of the coronal object is correct (good proportions) but
> there are 2 black borders (top and down)
>
> Something like that :
>
> +++++++++++++++++++
> +++++++++++++++++++
> +++++++++++++++++++
> ---CORONAL IMAGE---
> ---CORONAL IMAGE---
> ---CORONAL IMAGE---
> +++++++++++++++++++
> +++++++++++++++++++
> +++++++++++++++++++
>
> ('+' = black)
>
> In fact, I'd like the image to have the proportion "60 x 27.5 " (without any
> black borders...)
>
> ---CORONAL IMAGE---
> ---CORONAL IMAGE---
> ---CORONAL IMAGE---
>
>
> Do you see what I mean ?
>
> I've searched in the methods of vtkImageReslice but I didn't find what I'm
> looking for...
>
>
>
> Do you have any idea to help me ?
>
> Any help would be appreciated ;-)
>
> Thank you in advance !
>
>
>
> Stéphane
>
> _______________________________________________
> 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