[vtkusers] question about "ImageSlicing.cxx"

David Gobbi david.gobbi at gmail.com
Tue Nov 11 12:53:11 EST 2008


Hi Stephane,

I think that I understand what you are trying to do, but I really
think that your problem is because of the camera and not because of
vtkImageReslice.

The output of vtkImageReslice does have its own physical coordinate
system: if we say that matrix "A" is the ResliceAxes, and (x,y,z)
define the physical space of the axial image, and (x',y',z') define
the physical space of the coronal image, the the following simple
equation holds true:

  [x;y;z] = A [x';y';z']  (pretend these are column vectors)

In this equation, (x,y,z) and (x',y',z') are real physical coordinates
(i.e. in millimetres).

These real, physical coordinates are being mapped to screen
coordinates according to transformations that are done by the
vtkCamera and by the ViewPort of the renderer.  Unless you understand
what the Camera and ViewPort are doing, you won't be able to map mouse
coordinates to physical coordinates.

   David

On Tue, Nov 11, 2008 at 10:37 AM, Stéphane CALANDE <scalande at gmail.com> wrote:
> Thank you David, I'll try to change the background.
>
> But in fact, even if I saw that the borders were red, it wouldn't resolve my
> problem. I'm going to explain you why...
>
>
> Here's what I'd like :
>
> If I call something like :
>
> "window.SetSize(x,y)" (with x,y proportionnal to 60 x 27.5 => if you
> remember it is the real proportions of the coronal image)
>
> Have a look at http://info.fundp.ac.be/~scalande/borders2.PNG to
> understand...
>
>
>
> It is so important for me because I'm creating an interface that allow the
> select a region of the image with the mouse...
> So I have to do a conversion between the mouse coordinates and the image
> coordinates.
>
>
> I've another thing to say. In my example, the height of the coronal image is
> smaller than the height of the axial image. (60 > 27.5)
> And so there are borders... But if it was the contrary, if the coronal image
> height was 80, for example...
>
> Would the image be croped of 10 on top and 10 on down?
>
>
> To avoid the borders in the first case (<60) and the possible crop in the
> second case (>60), it would be really nice if the coronal views created by
> ImageReslice were represented in their own "physical space" (instead of the
> axial views physical space).
>
>
>
> Do you understand better ?
>
>
>
> I thank you one more time for the help,
>
>
>
> Stéphane
>
>
>
> 2008/11/11 David Gobbi <david.gobbi at gmail.com>
>>
>> Hi Stephane,
>>
>> When you get back to you office, try setting the background of the
>> renderer to red and I'm sure that you will see that the borders are
>> not part of the image.
>>
>> The reason that the borders don't disappear when you resize the window
>> is that everything in the vtkRenderer gets resized when you resize the
>> window.  That is always the behavior of vtkImageActor or any other
>> actor that is not a 2D actor: everything gets scaled relative to the
>> window size.
>>
>>   David
>>
>>
>>
>> On Tue, Nov 11, 2008 at 9:29 AM, Stéphane CALANDE <scalande at gmail.com>
>> wrote:
>> > Hi vtk-list, hi David,
>> >
>> >
>> >
>> > Thank you very much for your answer.
>> >
>> > I had already fixed the problem of zoom (that is not 1.0 by default)
>> > before.
>> >
>> > About the problem of the borders, I understand what you say, but I think
>> > that the borders are "really" included in the image.
>> > To be honnest, I can't try your advice beacuse I'm not in my office
>> > today,
>> > but I can give you other details to prove that the borders are included
>> > in
>> > the image.
>> >
>> > Even if I re-sized manually the window with the mouse (for example the
>> > height), all the image (the coronal subject and the borders) are
>> > proportionally reduced.
>> >
>> > (I've tinkered a PNG to explain this. Have a look at :
>> > http://info.fundp.ac.be/~scalande/borders.PNG
>> > But it's obviously not the real images because I'm not in my office
>> > today,
>> > it's just to give an example of the same effect...)
>> >
>> >
>> > If the black borders were "just" the background, they should slowly
>> > disappear during the re-sizing of the window... But it's not the case...
>> >
>> >
>> > I really have the impression that the coronal views created by
>> > ImageReslice
>> > are represented in the same "physic space" than the basic axial views
>> > (representing the volume).
>> >
>> >
>> > Can my explanation help you to understand the problem?
>> >
>> >
>> >
>> > Thank you very much for your help,
>> >
>> >
>> > Regards,
>> >
>> >
>> >
>> > Stéphane
>> >
>> >
>> >
>> >
>> >
>> >
>> > 2008/11/10 David Gobbi <david.gobbi at gmail.com>
>> >>
>> >> 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