<div dir="ltr">Use vtkImageViewer2 and use SetSlice to scroll through and setOrientationToXZ/... to set axial/sag/cor slices.<br><br>Jothy<br><br><div class="gmail_quote">On Tue, Jul 13, 2010 at 4:56 AM, Xiaopeng Yang <span dir="ltr">&lt;<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Dear all,</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I am trying to load a series of DICOM images and visualizing them
through VTK. Although I loaded several files, the VTK just visualized one
image. What I want is to visualize all of them through VTK, not just one file. It
is better that if I scroll the mouse wheel, I can review them slice by slice.
Anyone have the experience of doing this? Could you provide an example code?</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Attached is my code:</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: green;">//Define image parameters</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>   
<span style="color: blue;">float</span>    InputPixelType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>   
<span style="color: blue;">float</span>    OutputPixelType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::Image&lt; InputPixelType,  3 &gt;   InputImageType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::Image&lt; OutputPixelType, 3 &gt;   OutputImageType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: green;">// Load DICOM files</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::ImageSeriesReader&lt; InputImageType &gt;    
ReaderType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  ReaderType::Pointer reader = ReaderType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::GDCMImageIO                       
ImageIOType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::GDCMSeriesFileNames               
NamesGeneratorType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  ImageIOType::Pointer gdcmIO = ImageIOType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  NamesGeneratorType::Pointer namesGenerator =
NamesGeneratorType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  namesGenerator-&gt;SetInputDirectory( <span style="color: rgb(163, 21, 21);">&quot;C:/test&quot;</span> );</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">const</span>
ReaderType::FileNamesContainer &amp; filenames = </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">                           
namesGenerator-&gt;GetInputFileNames();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> numberOfFilenames =  filenames.size();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  std::cout &lt;&lt; numberOfFilenames &lt;&lt; <span style="color: rgb(163, 21, 21);">&quot; images loaded&quot;</span> &lt;&lt; std::endl; </span></p>


<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">for</span>(<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> fni = 0;
fni&lt;numberOfFilenames; fni++)</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    {</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    std::cout &lt;&lt; <span style="color: rgb(163, 21, 21);">&quot;filename # &quot;</span> &lt;&lt; fni &lt;&lt; <span style="color: rgb(163, 21, 21);">&quot; = &quot;</span>;</span></p>


<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    std::cout &lt;&lt; filenames[fni]
&lt;&lt; std::endl;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    }</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  reader-&gt;SetImageIO( gdcmIO );</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  reader-&gt;SetFileNames( filenames );</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">typedef</span>
itk::ImageToVTKImageFilter&lt;InputImageType&gt;FilterType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  FilterType::Pointer connector = FilterType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">try</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    {</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    reader-&gt;Update();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    }</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  <span style="color: blue;">catch</span>
(itk::ExceptionObject &amp;ex)</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    {</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    std::cout &lt;&lt; ex &lt;&lt;
std::endl;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    <span style="color: blue;">return</span>
EXIT_FAILURE;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">    }</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  connector-&gt;SetInput(reader-&gt;GetOutput());</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  vtkImageViewer *viewer = vtkImageViewer::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  viewer-&gt;SetupInteractor(renderWindowInteractor);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  viewer-&gt;SetInput(connector-&gt;GetOutput());</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  viewer-&gt;Render();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  viewer-&gt;SetColorWindow(255);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  viewer-&gt;SetColorLevel(128);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">  renderWindowInteractor-&gt;Start();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style="text-indent: 9pt;"><span style="font-size: 9pt; font-family: NSimSun; color: blue;">return</span><span style="font-size: 9pt; font-family: NSimSun;"> 0;</span><span style="font-size: 9pt; font-family: NSimSun;"></span></p>


<p class="MsoNormal" style="text-indent: 9pt;"><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal" style="text-indent: 9pt;"><span style="font-size: 9pt; font-family: NSimSun;"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Thank you very much!</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Xiaopeng</span></p>

</div>

</div>


<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
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>
<br>
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>
<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></blockquote></div><br></div>