[Insight-users] VTK's user's guide & camera
Renaud Isabelle
renauisa at yahoo.fr
Wed Jun 1 10:08:32 EDT 2005
Hi Luis,
It's me again.
- I didn't find the solution of my problem of camera.
m_Camera->SetPosition(Cx,Cy,1);
m_Camera->SetFocalPoint(Cx,Cy,0);
m_Camera->SetViewUp (0, 1, 0);
m_Camera->ParallelProjectionOn();
m_Renderer->SetActiveCamera(m_Camera);
m_Renderer->ResetCamera();
m_RenderWindow->SetSize(dimension[0], dimension[1]);
m_Camera->SetParallelScale( dimension[0]/2 );
m_RenderWindow->Render();
My camera is well positionned in space I think. However, my image is like kilometers far away of my camera: I can see my image's borders only after stretching my render window: it's like a small point so far away.
I know where my camera is positionned. But what i don't know is where my volume or my slice is in space. Maybe it depends on SetClippingRange() that I don't use for the moment..
- By the way, I am wondering if buying VTK's user's guide would be a good idea. Indeed, I'm working in medical image processing and I am sure that I will use ITK VTK for a long time. Or maybe do you have another suggestion of what I should get as guide.
Thanks,
Isabelle
Luis Ibanez <luis.ibanez at kitware.com> a écrit :
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 /* 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
>
>
---------------------------------
Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails, photos et vidéos !
Créez votre Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050601/3d9eb963/attachment.htm
More information about the Insight-users
mailing list