[vtkusers] camera

Luis Ibanez luis.ibanez at kitware.com
Fri May 27 17:19:56 EDT 2005


Hi Isabelle,


You are pointing the camera to the origin of coordinates

           m_Camera->SetFocalPoint(0,0,0);

That's usually located in the *corner* of the image.


You probably want to change that to be pointing to the
middle of the image, so the image gets centered in the
render window.

Typically if your image has

    (Nx,Ny) pixels and
    (Sx,Sy) millimeter of pixel size
    (Ox,Oy) origin in millimeters

then you want to set up your camera in front of the middle
of the image, and point to the center of the image:


     Cx = Nx * Sx / 2.0 + Ox
     Cy = Ny * Sy / 2.0 + Oy


    m_Camera->SetPosition(Cx,Cy,F);
    m_Camera->SetFocalPoint(Cx,Cy,0);


F is actually irrelevant here
since you are using ParallelProjection.

You don't want to put your "view up" to

    m_Camera->SetViewUp (0, 0, -1);

because the "up" of the image is actually along the Y axis.


A better choice for you might be:


    m_Camera->SetViewUp (0, 1, 0);



Note that, there is nothing misterious about positioning the
camera. Just think of your image as a 2D plane segment
floating in 3D space, and think of your camera as a
photograpic camera that must be placed in such a way that
you look at the middle of the image.



Regards,



    Luis


---------------------------
Renaud Isabelle wrote:

> Hi Luis,
>  
> I followed your advice and tried to create my own class to display my 
> image with VTK.
>  
> However, as Ì'm still new to VTK, I'm not familiar with all this notions 
> of camera, actor, mapper and so on. I tried to set up my own parameters  
> of a camera. However, I succed to view only a part of my image 1552*128.
>  
> Here is what I did: 
>  
>  * m_Camera        = vtkCamera::New();
>   m_Actor         = vtkImageActor::New();
>   m_Renderer      = vtkRenderer::New();
>   m_RenderWindow  = vtkRenderWindow::New();*
> ** 
> *  //setup the pipeline
>   m_Renderer->AddActor( m_Actor );
>   m_RenderWindow->AddRenderer( m_Renderer ); *
> * *
> *  // The usual rendering stuff
>   m_Camera->ComputeViewPlaneNormal();
>   m_Camera->SetViewUp (0, 0, -1);
>   m_Camera->SetPosition(0,0,1);
>   m_Camera->SetFocalPoint(0,0,0);
>   m_Camera->ParallelProjectionOn(); *
> ** 
> *  m_Renderer->SetActiveCamera(m_Camera);
>   m_Renderer->ResetCamera();
>   m_Renderer->SetBackground(0,0,0); //set a background color  *
> ** 
> *   m_Actor->SetInput( image)
>    m_Camera->SetClippingRange( 0.1, 1000.);
>    m_RenderWindow->Render();*
>  
> Do you think one or several parameters are not correct and explain my 
> result, If so, could you tell me which one.
>  
> Isabelle
> 
> */Luis Ibanez <luis.ibanez at kitware.com>/* a écrit :
> 
> 
>     Hi Isabelle,
> 
>     In order to have more control over the rendering of the image
>     you should replace the vtkImageViewer class with the individual
>     components used in ImageSliceViewer, namely:
> 
> 
>     vtkImageActor * m_Actor;
>     vtkRenderer * m_Renderer;
>     vtkCamera * m_Camera;
>     vtkRenderWindow * m_RenderWindow;
> 
> 
> 
>     The vtkImageViewer is actually a grouping of
> 
>     vtkRenderWindow *RenderWindow;
>     vtkRenderer *Renderer;
>     vtkImageMapper *ImageMapper;
>     vtkActor2D *Actor2D;
>     vtkRenderWindowInteractor *Interactor;
>     vtkInteractorStyleImage *InteractorStyle;
> 
> 
>     into a single class, just for convenience of use.
>     http://www.vtk.org/doc/nightly/html/classvtkImageViewer.html
> 
>     Regards,
> 
>     Luis
> 
> ------------------------------------------------------------------------
> Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos 
> mails, photos et vidéos !
> Créez votre Yahoo! Mail 
> <http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html> 
> 






More information about the vtkusers mailing list