<DIV>Hi luis,</DIV>
<DIV> </DIV>
<DIV>I did what you told me concerning the camera.Here is my code: </DIV>
<DIV> </DIV>
<DIV> <STRONG>vtkImageData * image = m_Actor->GetInput();<BR> </STRONG></DIV>
<DIV><STRONG> int dim[3]; image->GetDimensions(dim);<BR> float spacing[3]; image->GetSpacing(spacing);<BR> float origin[3]; image->GetOrigin(origin); <BR> </STRONG></DIV>
<DIV><STRONG> float Cx = (dim[0] * spacing[0])/2. + origin[0];<BR> float Cy = (dim[1] * spacing[1])/2. + origin[1];</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> m_Camera->SetPosition(Cx,Cy,1); <BR> m_Camera->SetFocalPoint(Cx,Cy,0); <BR> m_Camera->SetViewUp (0, 1, 0);</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> //parallel projection is used <BR> m_Camera->ParallelProjectionOn(); </STRONG></DIV>
<DIV><STRONG> m_Renderer->SetActiveCamera(m_Camera);<BR> m_Renderer->ResetCamera();</STRONG></DIV>
<DIV> </DIV>
<DIV>When displaying, all I can see in <STRONG>dark image</STRONG>. </DIV>
<DIV> </DIV>
<DIV>So I tried to <STRONG>zoom</STRONG>:</DIV>
<DIV> </DIV>
<DIV> //to fit the image to the render window, <BR> double max = MAX(spacing[0] * dim[0], spacing[1] * dim[1]);<BR> m_Camera-><STRONG>SetParallelScale</STRONG>( max/16. * m_ZoomFactor );</DIV>
<DIV> </DIV>
<DIV>I can see something only with a scale factor of max/16. My image is centered, so my camera is right in front of the middle of my slice, as you adviced me. But, <STRONG>why my volume is so far away of my camera?</STRONG> Yet, my camera position in Z axis is at Z=1. Where is my volume in Z axis? </DIV>
<DIV> </DIV>
<DIV>isabelle</DIV>
<DIV><BR><BR><B><I>Luis Ibanez <luis.ibanez@kitware.com></I></B> a écrit :</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi Isabelle,<BR><BR><BR>You are pointing the camera to the origin of coordinates<BR><BR>m_Camera->SetFocalPoint(0,0,0);<BR><BR>That's usually located in the *corner* of the image.<BR><BR><BR>You probably want to change that to be pointing to the<BR>middle of the image, so the image gets centered in the<BR>render window.<BR><BR>Typically if your image has<BR><BR>(Nx,Ny) pixels and<BR>(Sx,Sy) millimeter of pixel size<BR>(Ox,Oy) origin in millimeters<BR><BR>then you want to set up your camera in front of the middle<BR>of the image, and point to the center of the image:<BR><BR><BR>Cx = Nx * Sx / 2.0 + Ox<BR>Cy = Ny * Sy / 2.0 + Oy<BR><BR><BR>m_Camera->SetPosition(Cx,Cy,F);<BR>m_Camera->SetFocalPoint(Cx,Cy,0);<BR><BR><BR>F is actually irrelevant here<BR>since you are using ParallelProjection.<BR><BR>You don't want to put your "view up" to<BR><BR>m_Camera->SetViewUp (0, 0,
-1);<BR><BR>because the "up" of the image is actually along the Y axis.<BR><BR><BR>A better choice for you might be:<BR><BR><BR>m_Camera->SetViewUp (0, 1, 0);<BR><BR><BR><BR>Note that, there is nothing misterious about positioning the<BR>camera. Just think of your image as a 2D plane segment<BR>floating in 3D space, and think of your camera as a<BR>photograpic camera that must be placed in such a way that<BR>you look at the middle of the image.<BR><BR><BR><BR>Regards,<BR><BR><BR><BR>Luis<BR><BR><BR>---------------------------<BR>Renaud Isabelle wrote:<BR><BR>> Hi Luis,<BR>> <BR>> I followed your advice and tried to create my own class to display my <BR>> image with VTK.<BR>> <BR>> However, as Ì'm still new to VTK, I'm not familiar with all this notions <BR>> of camera, actor, mapper and so on. I tried to set up my own parameters <BR>> of a camera. However, I succed to view only a part of my image 1552*128.<BR>> <BR>> Here is what I did: <BR>>
<BR>> * m_Camera = vtkCamera::New();<BR>> m_Actor = vtkImageActor::New();<BR>> m_Renderer = vtkRenderer::New();<BR>> m_RenderWindow = vtkRenderWindow::New();*<BR>> ** <BR>> * //setup the pipeline<BR>> m_Renderer->AddActor( m_Actor );<BR>> m_RenderWindow->AddRenderer( m_Renderer ); *<BR>> * *<BR>> * // The usual rendering stuff<BR>> m_Camera->ComputeViewPlaneNormal();<BR>> m_Camera->SetViewUp (0, 0, -1);<BR>> m_Camera->SetPosition(0,0,1);<BR>> m_Camera->SetFocalPoint(0,0,0);<BR>> m_Camera->ParallelProjectionOn(); *<BR>> ** <BR>> * m_Renderer->SetActiveCamera(m_Camera);<BR>> m_Renderer->ResetCamera();<BR>> m_Renderer->SetBackground(0,0,0); //set a background color *<BR>> ** <BR>> * m_Actor->SetInput( image)<BR>> m_Camera->SetClippingRange( 0.1, 1000.);<BR>> m_RenderWindow->Render();*<BR>> <BR>> Do you think one or several parameters are not correct and explain my <BR>>
result, If so, could you tell me which one.<BR>> <BR>> Isabelle<BR>> <BR>> */Luis Ibanez <LUIS.IBANEZ@KITWARE.COM>/* a écrit :<BR>> <BR>> <BR>> Hi Isabelle,<BR>> <BR>> In order to have more control over the rendering of the image<BR>> you should replace the vtkImageViewer class with the individual<BR>> components used in ImageSliceViewer, namely:<BR>> <BR>> <BR>> vtkImageActor * m_Actor;<BR>> vtkRenderer * m_Renderer;<BR>> vtkCamera * m_Camera;<BR>> vtkRenderWindow * m_RenderWindow;<BR>> <BR>> <BR>> <BR>> The vtkImageViewer is actually a grouping of<BR>> <BR>> vtkRenderWindow *RenderWindow;<BR>> vtkRenderer *Renderer;<BR>> vtkImageMapper *ImageMapper;<BR>> vtkActor2D *Actor2D;<BR>> vtkRenderWindowInteractor *Interactor;<BR>> vtkInteractorStyleImage *InteractorStyle;<BR>> <BR>> <BR>> into a single class, just for convenience of use.<BR>>
http://www.vtk.org/doc/nightly/html/classvtkImageViewer.html<BR>> <BR>> Regards,<BR>> <BR>> Luis<BR>> <BR>> ------------------------------------------------------------------------<BR>> Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos <BR>> mails, photos et vidéos !<BR>> Créez votre Yahoo! Mail <BR>> <HTTP: *http: creer28.html mail fr.promotions.yahoo.com default taglines_1go splash mail_campaigns mail_fr us.rd.yahoo.com><BR>> <BR><BR><BR><BR></BLOCKQUOTE><p>
                <hr size=1>
Découvrez le nouveau Yahoo! Mail : <font color="red">1 Go d'espace</font> de stockage pour vos mails, photos et vidéos !<br><a href="http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html" target="_blank">Créez votre Yahoo! Mail</a>