Hi David,<br><br><br>You are right, the background has become red... And if I do a negative zoom, nothing was cropped.<br><br>Finally, I could resolve the problem by a simple :<br><br><br>camera->SetParallelScale( PHYSICAL_IMAGE_HEIGHT_VALUE / 2 );<br>
<br><br>Then, if I call a correct "window.SetSize(x,y)" (with x y proportionnal to the real dimensions of the coronal image), I'm sure that <u>all</u> the coronal image and <u>only</u> this image (without any border...) is displayed on the window... <br>
<br>After that it is very easy for me to convert mouse coordinates to image coordinates...<br><br><br><br>David, thank you very much for all... You were very helpful.<br><br><br>Have a very nice day,<br><br>Regards,<br><br>
<br><br><br>Stéphane<br><br><br><br><br><div class="gmail_quote">2008/11/11 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Stephane,<br>
<br>
I'm not sure if I understand completely, but there is no such thing as<br>
"too late" here because the image data never actually gets cropped.<br>
You see, vtkImageActor displays the image as an OpenGL texture, and<br>
textures don't get cropped in the way that you are thinking. The<br>
whole texture is always there in the graphics cards memory. It's just<br>
that the view of the texture is zoomed in so far that it doesn't all<br>
appear within your window. If you zoom out again, you'll always be<br>
able to see the whole thing.<br>
<br>
The zoom and pan operations in ImageSlicing.cxx are performed by the<br>
3D graphics hardware (and are controlled by the camera), while the<br>
reformatting and slicing are performed on the CPU by vtkImageReslice.<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Tue, Nov 11, 2008 at 11:23 AM, Stéphane CALANDE <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>> wrote:<br>
> Thank you David,<br>
><br>
><br>
> I am going to inquire about vtkCamera and vtkViewPort to better<br>
> understand...<br>
><br>
> I completely agree with you with the fact that I can easily resolve the<br>
> problem of my example with a simple zoom of the camera...<br>
><br>
> => if I was sure to be in the case 1 (27,5 < 60), I could resolve all my<br>
> problems with a zoom, and after that it would be easy to convert the<br>
> coordinates of the window(mouse) to coordinates of the images.<br>
><br>
> But what about the case 2 (80>60)...?<br>
> Even if I do a "negative zoom", I have the impression that it would be "too<br>
> late", I mean the image had already been cropped and a "negative" zoom would<br>
> just display new black borders top and down (instead of the 10 cm top and<br>
> down of the coronal image)<br>
><br>
> I hope you understand, it's not so easy to explain...<br>
><br>
> Concerning this case, I just wanted to ask you a last question...<br>
><br>
> I think I found something interresting in the vtkImageReslice documentation<br>
> (<a href="http://www.vtk.org/doc/nightly/html/classvtkImageReslice.html#ce80eced5f32389efe97e72612dec960" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkImageReslice.html#ce80eced5f32389efe97e72612dec960</a>)<br>
> :<br>
><br>
> virtual void vtkImageReslice::SetAutoCropOutput ( int<br>
> ) [virtual]<br>
><br>
> Turn this on if you want to guarantee that the extent of the output will be<br>
> large enough to ensure that none of the data will be cropped (default: Off).<br>
><br>
> I'm a newbie in vtk and I wanted to have your opinion : don't you think it's<br>
> what I'm looking for (to resolve the "case 2")?<br>
><br>
> I think it's the last time that I annoy you today with my problem ;-)<br>
><br>
> Have a very nice day,<br>
><br>
> Stéphane<br>
><br>
><br>
><br>
> 2008/11/11 David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>><br>
>> Hi Stephane,<br>
>><br>
>> I think that I understand what you are trying to do, but I really<br>
>> think that your problem is because of the camera and not because of<br>
>> vtkImageReslice.<br>
>><br>
>> The output of vtkImageReslice does have its own physical coordinate<br>
>> system: if we say that matrix "A" is the ResliceAxes, and (x,y,z)<br>
>> define the physical space of the axial image, and (x',y',z') define<br>
>> the physical space of the coronal image, the the following simple<br>
>> equation holds true:<br>
>><br>
>> [x;y;z] = A [x';y';z'] (pretend these are column vectors)<br>
>><br>
>> In this equation, (x,y,z) and (x',y',z') are real physical coordinates<br>
>> (i.e. in millimetres).<br>
>><br>
>> These real, physical coordinates are being mapped to screen<br>
>> coordinates according to transformations that are done by the<br>
>> vtkCamera and by the ViewPort of the renderer. Unless you understand<br>
>> what the Camera and ViewPort are doing, you won't be able to map mouse<br>
>> coordinates to physical coordinates.<br>
>><br>
>> David<br>
>><br>
>> On Tue, Nov 11, 2008 at 10:37 AM, Stéphane CALANDE <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>><br>
>> wrote:<br>
>> > Thank you David, I'll try to change the background.<br>
>> ><br>
>> > But in fact, even if I saw that the borders were red, it wouldn't<br>
>> > resolve my<br>
>> > problem. I'm going to explain you why...<br>
>> ><br>
>> ><br>
>> > Here's what I'd like :<br>
>> ><br>
>> > If I call something like :<br>
>> ><br>
>> > "window.SetSize(x,y)" (with x,y proportionnal to 60 x 27.5 => if you<br>
>> > remember it is the real proportions of the coronal image)<br>
>> ><br>
>> > Have a look at <a href="http://info.fundp.ac.be/%7Escalande/borders2.PNG" target="_blank">http://info.fundp.ac.be/~scalande/borders2.PNG</a> to<br>
>> > understand...<br>
>> ><br>
>> ><br>
>> ><br>
>> > It is so important for me because I'm creating an interface that allow<br>
>> > the<br>
>> > select a region of the image with the mouse...<br>
>> > So I have to do a conversion between the mouse coordinates and the image<br>
>> > coordinates.<br>
>> ><br>
>> ><br>
>> > I've another thing to say. In my example, the height of the coronal<br>
>> > image is<br>
>> > smaller than the height of the axial image. (60 > 27.5)<br>
>> > And so there are borders... But if it was the contrary, if the coronal<br>
>> > image<br>
>> > height was 80, for example...<br>
>> ><br>
>> > Would the image be croped of 10 on top and 10 on down?<br>
>> ><br>
>> ><br>
>> > To avoid the borders in the first case (<60) and the possible crop in<br>
>> > the<br>
>> > second case (>60), it would be really nice if the coronal views created<br>
>> > by<br>
>> > ImageReslice were represented in their own "physical space" (instead of<br>
>> > the<br>
>> > axial views physical space).<br>
>> ><br>
>> ><br>
>> ><br>
>> > Do you understand better ?<br>
>> ><br>
>> ><br>
>> ><br>
>> > I thank you one more time for the help,<br>
>> ><br>
>> ><br>
>> ><br>
>> > Stéphane<br>
>> ><br>
>> ><br>
>> ><br>
>> > 2008/11/11 David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>> >><br>
>> >> Hi Stephane,<br>
>> >><br>
>> >> When you get back to you office, try setting the background of the<br>
>> >> renderer to red and I'm sure that you will see that the borders are<br>
>> >> not part of the image.<br>
>> >><br>
>> >> The reason that the borders don't disappear when you resize the window<br>
>> >> is that everything in the vtkRenderer gets resized when you resize the<br>
>> >> window. That is always the behavior of vtkImageActor or any other<br>
>> >> actor that is not a 2D actor: everything gets scaled relative to the<br>
>> >> window size.<br>
>> >><br>
>> >> David<br>
>> >><br>
>> >><br>
>> >><br>
>> >> On Tue, Nov 11, 2008 at 9:29 AM, Stéphane CALANDE <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Hi vtk-list, hi David,<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > Thank you very much for your answer.<br>
>> >> ><br>
>> >> > I had already fixed the problem of zoom (that is not 1.0 by default)<br>
>> >> > before.<br>
>> >> ><br>
>> >> > About the problem of the borders, I understand what you say, but I<br>
>> >> > think<br>
>> >> > that the borders are "really" included in the image.<br>
>> >> > To be honnest, I can't try your advice beacuse I'm not in my office<br>
>> >> > today,<br>
>> >> > but I can give you other details to prove that the borders are<br>
>> >> > included<br>
>> >> > in<br>
>> >> > the image.<br>
>> >> ><br>
>> >> > Even if I re-sized manually the window with the mouse (for example<br>
>> >> > the<br>
>> >> > height), all the image (the coronal subject and the borders) are<br>
>> >> > proportionally reduced.<br>
>> >> ><br>
>> >> > (I've tinkered a PNG to explain this. Have a look at :<br>
>> >> > <a href="http://info.fundp.ac.be/%7Escalande/borders.PNG" target="_blank">http://info.fundp.ac.be/~scalande/borders.PNG</a><br>
>> >> > But it's obviously not the real images because I'm not in my office<br>
>> >> > today,<br>
>> >> > it's just to give an example of the same effect...)<br>
>> >> ><br>
>> >> ><br>
>> >> > If the black borders were "just" the background, they should slowly<br>
>> >> > disappear during the re-sizing of the window... But it's not the<br>
>> >> > case...<br>
>> >> ><br>
>> >> ><br>
>> >> > I really have the impression that the coronal views created by<br>
>> >> > ImageReslice<br>
>> >> > are represented in the same "physic space" than the basic axial views<br>
>> >> > (representing the volume).<br>
>> >> ><br>
>> >> ><br>
>> >> > Can my explanation help you to understand the problem?<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > Thank you very much for your help,<br>
>> >> ><br>
>> >> ><br>
>> >> > Regards,<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > Stéphane<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > 2008/11/10 David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>> >> >><br>
>> >> >> Hi Stephane,<br>
>> >> >><br>
>> >> >> The black borders that you see in this example are actually the<br>
>> >> >> background in the renderer. If you add<br>
>> >> >> "renderer->SetBackground(1.0,0.0,0.0);" to the example, then you<br>
>> >> >> will<br>
>> >> >> see the black bars turn to red.<br>
>> >> >><br>
>> >> >> In other words, it isn't vtkImageReslice that is adding these<br>
>> >> >> borders.<br>
>> >> >> These borders are present because the RenderWindow is square, and<br>
>> >> >> vtkImageReslice has no control over the window size.<br>
>> >> >><br>
>> >> >> So what you need to do is call window->SetSize() to set the size of<br>
>> >> >> the window to the size of your image. You can call Update() on<br>
>> >> >> ImageReslice and get the size of its output, so that you know what<br>
>> >> >> size to make the window.<br>
>> >> >><br>
>> >> >> Even after you do this, though, you will still have to do one more<br>
>> >> >> thing. By default, the zoom factor for camera is not 1.0. You will<br>
>> >> >> have to call add code like the following:<br>
>> >> >><br>
>> >> >> vtkCamera *camera = renderer->GetActiveCamera();<br>
>> >> >><br>
>> >> >> camera->SetViewAngle(2.0*atan(0.5*height_of_image/camera_distance));<br>
>> >> >><br>
>> >> >> Alternatively, you can switch to parallel projections, which makes<br>
>> >> >> the<br>
>> >> >> math easier but I'm not sure if the VTK interactors all work<br>
>> >> >> properly<br>
>> >> >> in parallel mode:<br>
>> >> >><br>
>> >> >> camera->ParallelProjectionOn();<br>
>> >> >> camera->SetParallelScale(height_of_image);<br>
>> >> >><br>
>> >> >> I hope this is what you were looking for,<br>
>> >> >><br>
>> >> >> David<br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >> On Mon, Nov 10, 2008 at 9:38 AM, Stéphane CALANDE<br>
>> >> >> <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>><br>
>> >> >> wrote:<br>
>> >> >> > Hi,<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > I'm trying "ImageSlicing.cxx" to display an "coronal" slice from a<br>
>> >> >> > volume<br>
>> >> >> > (multiple axial slices).<br>
>> >> >> ><br>
>> >> >> > It works well, but there is just a problem.<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Information about my axial slices :<br>
>> >> >> ><br>
>> >> >> > SIZE : 512 x 512<br>
>> >> >> > SPACING : (1,17188 ; 1,17188)<br>
>> >> >> ><br>
>> >> >> > "REAL" SIZE = 60 cm x 60 cm<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Information about the coronal slices that SHOULD be created<br>
>> >> >> ><br>
>> >> >> > SIZE : 512 x 55<br>
>> >> >> > SPACING : (1,17188 ; 5)<br>
>> >> >> ><br>
>> >> >> > "REAL" SIZE = 60 cm x 27.5 cm<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > But the problem is that the image created by "ImageSlicing" has<br>
>> >> >> > the<br>
>> >> >> > shape of<br>
>> >> >> > a square.<br>
>> >> >> > I mean it has the same shape than the axial images.<br>
>> >> >> ><br>
>> >> >> > The representation of the coronal object is correct (good<br>
>> >> >> > proportions)<br>
>> >> >> > but<br>
>> >> >> > there are 2 black borders (top and down)<br>
>> >> >> ><br>
>> >> >> > Something like that :<br>
>> >> >> ><br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> > +++++++++++++++++++<br>
>> >> >> ><br>
>> >> >> > ('+' = black)<br>
>> >> >> ><br>
>> >> >> > In fact, I'd like the image to have the proportion "60 x 27.5 "<br>
>> >> >> > (without<br>
>> >> >> > any<br>
>> >> >> > black borders...)<br>
>> >> >> ><br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> > ---CORONAL IMAGE---<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Do you see what I mean ?<br>
>> >> >> ><br>
>> >> >> > I've searched in the methods of vtkImageReslice but I didn't find<br>
>> >> >> > what<br>
>> >> >> > I'm<br>
>> >> >> > looking for...<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Do you have any idea to help me ?<br>
>> >> >> ><br>
>> >> >> > Any help would be appreciated ;-)<br>
>> >> >> ><br>
>> >> >> > Thank you in advance !<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Stéphane<br>
>> >> >> ><br>
>> >> >> > _______________________________________________<br>
>> >> >> > This is the private VTK discussion list.<br>
>> >> >> > Please keep messages on-topic. Check the FAQ at:<br>
>> >> >> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
>> >> >> > Follow this link to subscribe/unsubscribe:<br>
>> >> >> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> ><br>
>> >> ><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>