<DIV id=RTEContent> <DIV id=RTEContent><PRE>hi All<BR>I'm developping an application that 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 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> 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 = 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 (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>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> 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> 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 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 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 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> "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 =
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> 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>
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 = 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 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 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><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.