<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"><<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>></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< InputPixelType, 3 > InputImageType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> <span style="color: blue;">typedef</span>
itk::Image< OutputPixelType, 3 > 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< InputImageType >
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->SetInputDirectory( <span style="color: rgb(163, 21, 21);">"C:/test"</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 & filenames = </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;">
namesGenerator->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 << numberOfFilenames << <span style="color: rgb(163, 21, 21);">" images loaded"</span> << 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<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 << <span style="color: rgb(163, 21, 21);">"filename # "</span> << fni << <span style="color: rgb(163, 21, 21);">" = "</span>;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> std::cout << filenames[fni]
<< 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->SetImageIO( gdcmIO );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> reader->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<InputImageType>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->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 &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 << ex <<
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->SetInput(reader->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->SetupInteractor(renderWindowInteractor);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> viewer->SetInput(connector->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> viewer->Render();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> viewer->SetColorWindow(255);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: NSimSun;"> viewer->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->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>