<div id="RTEContent">wa alaykom assalam<br> plz read the <span style="font-weight: bold;">itk software guide.pdf </span>section <span style="font-style: italic;">7.12.3 Reading a 2D DICOM Series and Writing a Volume</span><br>and this is a part of code of file <span style="font-style: italic; text-decoration: underline;">Examples/IO/DicomSeriesReadImageWrite2.cxx :<br> <span style="font-style: italic;"><span style="text-decoration: underline;"><br> </span></span></span><span style="font-style: italic;"><span style="font-style: italic;">typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer dicomIO = ImageIOType::New();<br> reader->SetImageIO( dicomIO );<br> <br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br> nameGenerator->SetUseSeriesDetails( true );<br> nameGenerator->SetDirectory( argv[1] );<br> <br> typedef std::vector< std::string
> SeriesIdContainer;<br> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br> SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br> <br> //here we browse all the series in the directory<br> <br> while( seriesItr != seriesEnd )<br> {<br> std::cout << seriesItr->c_str() << std::endl;<br> seriesItr++;<br> }<br> <br> // and here we choose one serie from the list by its ID given in the command line<br> //and if no ID specifies by user, we take the first serie in the list<br> <br> std::string seriesIdentifier;<br> if( argc > 3 ) // If no optional series identifier<br> {<br> seriesIdentifier = argv[3];<br> }<br> else<br> {<br> seriesIdentifier = seriesUID.begin()->c_str();<br> }<br> <br> typedef std::vector< std::string > FileNamesContainer;<br> FileNamesContainer
fileNames;<br> <br> //here we read list of files belonging to the serie we choose<br> <br> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br> <br> reader->SetFileNames( fileNames );<br> <br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject &ex)<br> {<br> std::cout << ex << std::endl;<br> return EXIT_FAILURE;<br> }<br> ***********************************************************************************<br> </span></span><span style="font-style: italic;"><span style="font-style: italic;">//so if u want to deal with every slice alone, u might write something like this<br> <br> </span></span><span style="font-style: italic;"><span style="font-style: italic;">SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br> </span></span><span style="font-style: italic;"><span style="font-style:
italic;"> std::string seriesIdentifier;<br> </span></span><span style="font-style: italic;"><span style="font-style: italic;"> typedef std::vector< std::string > FileNamesContainer;<br> FileNamesContainer fileNames;<br> <br> </span></span><span style="font-style: italic;"><span style="font-style: italic;"> //here we browse all the series in the directory<br> <br> while( seriesItr != seriesEnd )<br> {<br> </span></span><span style="font-style: italic;"><span style="font-style: italic;">seriesIdentifier = </span></span><span style="font-style: italic;"><span style="font-style: italic;">seriesItr->c_str()</span></span><span style="font-style: italic;"><span style="font-style: italic;">;</span></span><br> <span style="font-style: italic;"><span style="font-style: italic;"> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br> reader->SetFileNames( fileNames );<br> </span></span><span style="font-style: italic;"><span
style="font-style: italic;"> reader->Update();</span></span><br> <br> {<br> <span style="font-style: italic;">// here you write code to process each serie alone</span><br> }<br> <br> <span style="font-style: italic;"><span style="font-style: italic;"> seriesItr++;<br> }<br> <br> </span></span><span style="font-style: italic;"><span style="font-style: italic;"><br> <br></span></span>For more comments plz read the ITK SOFTWARE GUIDE.PDF from page 298.<br> let me know if u resolve your problem, or didn't i understand what u need.<br> Amir.<br> Technology & Medical Imaging Lab<br> Biophysics Departement<br> Faculty of Medecine Monastir-Tunisia<span style="font-style: italic; text-decoration: underline;"><span style="font-style: italic;"><span style="text-decoration: underline;"><span style="font-style: italic;"><span style="text-decoration:
underline;"></span></span><br> <br> <br> </span></span></span><span style="text-decoration: underline;"></span><b><i>mahmoud ismail <mahmoudtheleader2003@yahoo.com></i></b> a écrit :<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> <div>salamo alikom</div> <div>My problem is that i use vtkDicomReader class and it has a restriction which is</div> <div> (the folder that contains the images must have images that belong to the same series and are ordered) . but in most cases the folder contain images that belongs to more than one series</div> <div>so i want to deal with every series alone </div> <div>is it clear</div> <div> </div> <div>Note my name is mahmoud mohamed Ahmed</div> <div>and I am in fourth year systems & and biomedical enginnering department Cairo university Egypt</div> <div>what about u<br><br><b><i>charfeddine amir <charfeddine_amir@yahoo.fr></i></b>
wrote:</div> <blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"> <div id="RTEContent">salam <br>sorry i didn't understand your problem<br>i hope you finded a solution, if not, rewrite me and explain me your problem<br>because i think i can help u<br>i make an application that read dicom series but don't show me all image...<br>regards,<br><br><b><i>mahmoud ismail <mahmoudtheleader2003@yahoo.com></i></b> a écrit : <blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"> <div>hi Amir</div> <div>first i have no answer to your question and hope that the message yuo have recieved </div> <div>is enough but</div> <div>I try to open Dicom Images using VTKDicomReader class</div> <div>but it cann't distinguish between images that belong to different series</div> <div> </div> <div>so i used GDCM but i have some problems with it </div> <div>Do u have
any suggestions </div> <div>Thanks<br><br><b><i>charfeddine amir <charfeddine_amir@yahoo.fr></i></b> wrote:</div> <blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"> <div id="RTEContent"> <div id="RTEContent"><pre>hi All<br>I'm developping an application that<br> reads the first serie of<br>Dicom images from a directory, show each image and save it<br>in bmp format.<br>the problem is that image series is well readed, and image<br> are well saved in bmp format, but image are not well showed<br>in the vtkrenderwindow used ( i get a black window with<br> two<br>white line on it and not the image readed).<br>this code in the main file :<br><br>this function is for reading first series from a given <br>directory and showing it's first dicom image(invoked by <br>pushing the Read Directory button in the GUI)<br>void<br>migAppBase<br>::ReadImage()<br>{<br> // Can only read an image once<br>
if(m_InputImage.IsNotNull()) <br> return;<br> <br> char* chooserName = fl_dir_chooser("select a dicom directory", 0, 0);<br><br> // Store the filename<br> strcpy( m_InputImageDirectoryname, chooserName );<br> reader = ReaderType::New(); <br> dicomIO = ImageIOType::New();<br> nameGenerator = NamesGeneratorType::New();<br> <br> reader->SetImageIO( dicomIO );<br> nameGenerator->SetUseSeriesDetails( true );<br> nameGenerator->SetDirectory( m_InputImageDirectoryname ); <br> seriesUID = nameGenerator->GetSeriesUIDs();<br> <br> seriesIdentifier = seriesUID.begin()->c_str();<br> <br> fileNames =<br> nameGenerator->GetFileNames( seriesIdentifier );<br><br> FileNamesItr = fileNames.begin ();<br> FileNamesEnd = fileNames.end();<br> <br> <br> rescaler = RescaleFilterType::New();<br> rescaler->SetOutputMinimum( 0 );<br> rescaler->SetOutputMaximum( 255 );<br> reader->SetFileName( FileNamesItr->c_str() ); <br><br> try<br>
{<br> rescaler->SetInput( reader->GetOutput() );<br> reader->Update();<br> m_InputImage = reader->GetOutput();<br> m_InputImage->SetRequestedRegionToLargestPossibleRegion(); <br> <br> // Create the input image VTK pipeline<br> this->CreateInputImageWindow();<br><br> }<br> catch<br> (itk::ExceptionObject &ex)<br> {<br> }<br><br> FileNamesItr++;<br>}<br><br>this function is for reading the next image in the serie <br>(invoked by pushing the Read Next button in the GUI)<br><br> void<br>migAppBase<br>::ReadNext()<br>{<br><br><br>if ( FileNamesItr != FileNamesEnd<br> )<br>{<br><br>reader->SetFileName( FileNamesItr->c_str() );<br><br> try<br> {<br> rescaler->SetInput( reader->GetOutput() );<br> m_InputImage = reader->GetOutput();<br> m_InputImage->SetRequestedRegionToLargestPossibleRegion();<br> reader->Update();<br> // Create the input image VTK pipeline <br>
this->CreateInputImageWindow();<br><br> }<br> catch (itk::ExceptionObject &ex)<br> {<br> }<br>FileNamesItr++;<br>}<br>}<br><br>this function is for saving the actual image (that should<br> be showed in the vtk window) in bmp format (invoked by <br>pushing the save Image in the GUI)<br><br><br> void<br>migAppBase<br>::SaveImage()<br>{<br><br>Writer2Type::Pointer writer2 = Writer2Type::New();<br><br>std::string OutputFilename1 = FileNamesItr->c_str() + std::string(".bmp"); <br>writer2->SetFileName( OutputFilename1.c_str() );<br>writer2->SetInput( rescaler->GetOutput() );<br><br> try<br> {<br> <br> writer2->Update();<br> }<br> catch (itk::ExceptionObject & e)<br> {<br> }<br><br>}<br><br>this is the fuction for showing the actual image<br><br>void<br>migAppBase<br>::CreateInputImageWindow()<br>{<br> // If this is the first time we've hit Image Suivante there's other stuff<br> // that needs to happen <br>
if(m_IsFirstUpdate)<br> {<br> // Display the output image<br> CreateWindowWithRWI(m_InputInteractor, m_InputWindow, "Input Image");<br><br> // these two steps are VERY IMPORTANT, you have to show() the fltk window <br> // containing the vtkFlRenderWindowInteractor, and then the<br> // vtkFlRenderWindowInteractor<br> itself<br> m_InputWindow->show();<br> m_InputInteractor->show();<br> <br> // now we get to setup our VTK rendering pipeline <br> CreateInputImageVTKPipeline(m_InputInteractor);<br><br> // No longer the first update<br> m_IsFirstUpdate = false;<br> }<br> else<br> {<br> // Refresh the output window if not the<br> first update<br> // NB: doing this on the first update on Windows causes a new <br> // renderwindow to spawn (not sure why)<br> m_InputRenderWindow->Render();<br> }<br> <br>}<br><br>function(s) for fltk and vtk interaction( creation of the<br>vtkrenderwindow and integrating it to the fltk window)
<br><br>void<br>migAppBase<br>::CreateWindowWithRWI(vtkFlRenderWindowInteractor *&flrwi, Fl_Window *&flw, char *title)<br>{<br> // set up main FLTK window<br> flw = new Fl_Window(300,330,title);<br> <br> // and instantiate vtkFlRenderWindowInteractor (here it acts like a <br> // FLTK window, i.e. you could also<br> instantiate it as child of a<br> // Fl_Group in a window)<br> flrwi = new vtkFlRenderWindowInteractor(5,5,290,260,NULL);<br><br> // this will result in a little message under the rendering <br> Fl_Box* box = new Fl_Box(5,261,290,34,<br> "3 = stereo, j = joystick, t = trackball, "<br> <br> "w = wireframe, s = surface, p = pick; "<br> "you can also resize the window"); <br> box->labelsize(10);<br> box->align(FL_ALIGN_WRAP);<br> <br> // we're done populating the flw<br> flw->end();<br><br> // if the main window gets resized, the vtk window
should resize with it<br> flw->resizable(flrwi); <br>}<br><br>void<br>migAppBase<br>::CreateInputImageVTKPipeline(vtkFlRenderWindowInteractor *flrwi)<br>{<br> // Abort if the user is being stupid<br> if(m_InputImage.IsNull()) <br> return;<br><br> // create a rendering window and renderer <br> m_InputRenderer = <br> vtkRenderer::New();<br> m_InputRenderer->SetBackground(0.0, 0.0, 0.0);<br> <br> m_InputRenderWindow = vtkRenderWindow::New();<br> m_InputRenderWindow->AddRenderer(m_InputRenderer);<br> <br> // NB: here we treat the vtkFlRenderWindowInteractor just like any other<br> // old vtkRenderWindowInteractor<br> <br> flrwi->SetRenderWindow(m_InputRenderWindow);<br><br> // Hook the VTK pipeline up to the ITK pipeline <br> m_InputImageITKtoVTKexporter = itk::VTKImageExport<InputImageType>::New();<br> m_InputImageVTKimporter = vtkImageImport::New();<br> m_InputImageITKtoVTKexporter->SetInput( m_InputImage );<br>
ConnectPipelines(m_InputImageITKtoVTKexporter, m_InputImageVTKimporter); <br><br> // Need to update prior to creating the cutting planes<br> m_InputImageITKtoVTKexporter->Update();<br> m_InputImageVTKimporter->Update();<br><br> // Create the image cutting planes<br> m_InputImagePlaneX = vtkImagePlaneWidget::New(); <br> <br> m_InputImagePlaneX->RestrictPlaneToVolumeOn();<br> m_InputImagePlaneX->SetResliceInterpolateToCubic();<br> m_InputImagePlaneX->SetInput( (vtkDataSet*) m_InputImageVTKimporter->GetOutput() );<br> m_InputImagePlaneX->SetPlaneOrientationToXAxes(); <br> m_InputImagePlaneX->SetSliceIndex( 0 );<br> <br> m_InputImagePlaneY =<br> vtkImagePlaneWidget::New();<br> m_InputImagePlaneY->RestrictPlaneToVolumeOn();<br> m_InputImagePlaneY->SetResliceInterpolateToCubic(); <br> m_InputImagePlaneY->SetInput( (vtkDataSet*) m_InputImageVTKimporter->GetOutput() );<br> m_InputImagePlaneY->SetPlaneOrientationToYAxes();<br>
m_InputImagePlaneY->SetSliceIndex( 0 );<br> // Set the position of the image planes to the center of the volume <br> this->ResetInputImagePlaneWidgets();<br><br> // Link the image planes to the interactor<br> m_InputImagePlaneX->SetInteractor( flrwi );<br> m_InputImagePlaneY->SetInteractor( flrwi );<br><br> // Turn on the<br> image plane so they display <br> m_InputImagePlaneX->On();<br> m_InputImagePlaneY->On();<br><br> // just like with any other vtkRenderWindowInteractor(), you HAVE to call<br> // Initialize() before the interactor will function. See the docs in <br> // vtkRenderWindowInteractor.h<br> // This must occur AFTER the image planes have<br> been added to the interactor<br> flrwi->Initialize();<br><br> // Clean up memory allocation (NB: not actually deleted until program returns) <br> m_InputRenderer->Delete();<br> m_InputRenderWindow->Delete();<br>}<br><br>thx for help<br>any comment is
welcome<br>Amir</pre></div></div> <div> <hr size="1"> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international. <a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta._______________________________________________<br>This is the private VTK discussion list. <br>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<br>Follow this link to subscribe/unsubscribe:<br>http://www.vtk.org/mailman/listinfo/vtkusers<br></div></blockquote> <div><br></div> <div></div> <hr size="1"> Yahoo! Photos<br>Ring in the New Year with <a href="http://us.rd.yahoo.com/mail_us/taglines/photos/*http://pa.yahoo.com/*http://us.rd.yahoo.com/mail_us/taglines/photos/evt=38087/*http://pg.photos.yahoo.com/ph//page?.file=calendar_splash.html&.dir=">Photo Calendars</a>. Add photos, events, holidays,
whatever.</blockquote><br></div> <div> <hr size="1"> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international. <a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta.</div></blockquote> <div><br></div><div> </div><hr size="1">Do you Yahoo!?<br> With a free 1 GB, there's more in store with <a href="http://us.rd.yahoo.com/mail_us/taglines/mailstorage/*http://mail.yahoo.com/">Yahoo! Mail.</a></blockquote><br></div><p>
                <hr size=1> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta.