<div dir="ltr">If you use vtkImageViewer2, you shouls use setSlice and setorientationTo methods to set the desired orientation adn the slice no after setting the setInput/setinputConnection.<br><br>have a look at this link<br>
<br><a href="http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=47&amp;Itemid=27">http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=47&amp;Itemid=27</a><br><br>Jothy<br><br><div class="gmail_quote">
On Thu, Jun 30, 2011 at 4:01 PM, mathilde.merle <span dir="ltr">&lt;<a href="mailto:mathilde.merle@laposte.net">mathilde.merle@laposte.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>I use <i>vtkImageViewer2 :</i><br><i><br>    // VIEWER TOOL : Pick a Pixel<br>    // Picker to pick pixels<br>    vtkSmartPointer&lt;vtkPropPicker&gt; propPicker = vtkSmartPointer&lt;vtkPropPicker&gt;::New();<br>    propPicker-&gt;PickFromListOn();<br>
    <br>    // Give the picker a prop to pick<br>    vtkSmartPointer&lt;vtkImageViewer2&gt; imageViewer = vtkSmartPointer&lt;vtkImageViewer2&gt;::New();<br>    vtkImageActor* imageActor = imageViewer-&gt;GetImageActor();<br>
    propPicker-&gt;AddPickList(imageActor);<br>    <br>    // disable interpolation, so we can see each pixel<br>    imageActor-&gt;InterpolateOff();</i><br><br><blockquote style="padding-left:5px;margin-left:5px;border-left:2px solid #ff0000">
&gt; Message du 30/06/11 15:54<br>&gt; De : &quot;Jothy&quot; <br>&gt; A : &quot;mathilde.merle&quot; <br>&gt; Copie à : &quot;vtkusers vtk org&quot; <br>&gt; Objet : Re: [vtkusers] Extract slices from a vtkMetaImageReader with vtkExtractVOI<br>
&gt;<br>&gt; <p style="margin:0;padding:0" dir="ltr"></p><div class="im">Which image viewer are you using here?<br>&gt; <br>&gt; Jothy<br>&gt; <br>&gt; </div><p style="margin:0;padding:0" class="gmail_quote"></p><div class="im">
On Thu, Jun 30, 2011 at 3:41 PM, mathilde.merle <span>&lt;<a href="mailto:mathilde.merle@laposte.net" target="_blank">mathilde.merle@laposte.net</a>&gt;</span> wrote:<br>&gt;  </div><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid #cccccc;padding-left:1ex">
<div class="im"><p style="margin:0pt;padding:0pt" align="left"><br>&gt; </p><br>&gt; Hello,<br>&gt; <br>&gt; I&#39;m trying to extract slices from a vtkImagedata sequence and then display it. <br>&gt;  <br>&gt; I tryed with vtkImageReslice and then vtkextractVOI, but it don&#39;t work. The image displayed is always the same even if I change &#39;slice_nb&#39;. <br>
&gt; <br>&gt; How can I do ?<br>&gt; <br>&gt; My code :<br>&gt; </div><i><br><div class="im">&gt; int* dims = reader-&gt;GetOutput()-&gt;GetDimensions();<br>&gt;  <br>&gt; // extract slice<br>&gt; <br>&gt; <b>int slice_nb = 0;</b><br>
&gt; <br></div>&gt; <b>vtkSmartPointer extractVOI = vtkSmartPointer::New();<div class="im"><br>&gt;     extractVOI-&gt;SetInputConnection(reader-&gt;GetOutputPort());<br>&gt;      extractVOI-&gt;SetVOI(0,dims[0],0,dims[1], slice_nb, slice_nb); //extract first image<br>
&gt;     extractVOI-&gt;Update();</div></b><div class="im"><br>&gt;     <br>&gt;     vtkImageData* extracted = extractVOI-&gt;GetOutput();<br>&gt; <br>&gt;     int* dims2 = extracted-&gt;GetDimensions();<br>&gt;      cout &lt;&lt; &quot;DimensionsExtracted = &quot;;<br>
&gt;     for (int i=0; i&lt;(int)(sizeof(dims2)/sizeof(int)+1); i++) { <br>&gt;         cout &lt;&lt; dims2[i]&lt;&lt;&quot;, &quot;;<br>&gt;     }<br>&gt;     cout &lt;&lt; endl; // Get a good image dimension<br>&gt;      <br>
&gt; // Visualize<br></div>&gt;     vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();<div class="im"><br>&gt;     imageViewer-&gt;SetInputConnection(<b>extractVOI-&gt;GetOutputPort() </b>);<br>&gt;      imageViewer-&gt;SetupInteractor( renderWindowInteractor );<br>
&gt;     imageViewer-&gt;SetSize( 600, 600 );<br>&gt;     <br>&gt;     vtkRenderer* renderer = imageViewer-&gt;GetRenderer();<br>&gt;     renderer-&gt;ResetCamera();<br>&gt;     renderer-&gt;GradientBackgroundOn();<br>&gt;      renderer-&gt;SetBackground(0,0,0);<br>
&gt;     renderer-&gt;SetBackground2(1,1,1);<br>&gt;     <br>&gt;     // Annotate the image with window/level and mouse over pixel information<br></div>&gt;     vtkSmartPointer cornerAnnotation = vtkSmartPointer::New();<div class="im">
<br>&gt;      cornerAnnotation-&gt;SetLinearFontScaleFactor( 2 );<br>&gt;     cornerAnnotation-&gt;SetNonlinearFontScaleFactor( 1 );<br>&gt;     cornerAnnotation-&gt;SetMaximumFontSize( 20 );<br>&gt;     cornerAnnotation-&gt;SetText( 0, &quot;Off Image&quot; );<br>
</div>&gt;      cornerAnnotation-&gt;SetText( 3, &quot;\n&quot; );<div class="im"><br>&gt;     cornerAnnotation-&gt;GetTextProperty()-&gt;SetColor( 1,0,0);<br>&gt;     <br>&gt;     imageViewer-&gt;GetRenderer()-&gt;AddViewProp( cornerAnnotation );<br>
&gt;      <br>&gt;     // Callback listens to MouseMoveEvents invoked by the interactor&#39;s style<br></div>&gt;     vtkSmartPointer callback = vtkSmartPointer::New();<div class="im"><br>&gt;     callback-&gt;SetViewer( imageViewer );<br>
&gt;      callback-&gt;SetAnnotation( cornerAnnotation );<br>&gt;     callback-&gt;SetPicker( propPicker );<br>&gt;     callback-&gt;SetOrigin( orgn[0], orgn[1], orgn[2]); // add the origin of the sequence into the class<br>
&gt; <br>&gt;  // Events recognized <br>&gt;      vtkInteractorStyleImage* imageStyle = imageViewer-&gt;GetInteractorStyle();<br>&gt;     imageStyle-&gt;AddObserver( vtkCommand::MouseMoveEvent, callback );<br>&gt;     imageStyle-&gt;AddObserver( vtkCommand::LeftButtonReleaseEvent, callback );<br>
&gt;  <br>&gt;     renderWindowInteractor-&gt;Initialize();<br>&gt;     renderWindowInteractor-&gt;Start();  </div></i>  <br><div class="im">&gt; <br>&gt; <br>&gt; Thanks<br>&gt; <font color="#888888"><br>&gt; Mathilde<span style="color:#808000"></span><br>
&gt; <br>&gt; <a href="https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique" target="_blank"><img src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg"></a></font><br>
&gt;  _______________________________________________<br>&gt;  Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt;  <br>&gt;  Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;  <br>&gt;  Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;  <br>&gt;  Follow this link to subscribe/unsubscribe:<br>
&gt;  <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;  <br>&gt; </div></blockquote><p></p><br>&gt; <p></p> </blockquote><br><br><a href="https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique" target="_blank"><img style="margin:0pt" src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg" alt=""></a><a></a></blockquote>
</div><br></div>