[Insight-users] WatershedImageFilter

Yusuf OEZBEK nasil122002 at yahoo.de
Wed Jan 6 18:01:54 EST 2010


Hello,

I need help with my following problem.
How can I show my DICOM images as 3D (volumetric display) with VTK?
I read the DICOM images with itk::ImageSeriesReader and filter it with itk::WatershedImageFilter. For the connection between ITK and VTK I use itk:: ImageToVTKImageFilter. What classes should I use this in VTK, so that a volumetric display is out.


My Code:


  	typedef unsigned char    PixelType;
  	const unsigned int      Dimension = 3;

  	typedef itk::OrientedImage< PixelType, Dimension > ImageType;
  	typedef itk::ImageSeriesReader< ImageType > ReaderType;
  	typedef itk::GDCMImageIO ImageIOType;
  	typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  	typedef std::vector< std::string >    SeriesIdContainer;
 	typedef std::vector< std::string >   FileNamesContainer;

  	ImageIOType::Pointer dicomIO = ImageIOType::New();

    	ReaderType::Pointer reader = ReaderType::New();
  	reader->SetImageIO( dicomIO );

  	NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
  	nameGenerator->SetUseSeriesDetails( true );
  	nameGenerator->AddSeriesRestriction("0008|0021" );
  	nameGenerator->SetDirectory( selectedDirectory);

  	const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
  	SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
  	SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();

    	 while( seriesItr != seriesEnd )
     	 {
      		seriesItr++;
      	 }

 	std::string seriesIdentifier;
 	seriesIdentifier = seriesUID.begin()->c_str();

 	FileNamesContainer fileNames;
 	fileNames = nameGenerator->GetFileNames( seriesIdentifier );

 	reader->SetFileNames( fileNames );
 	reader->Update();


 	typedef float                             InternalPixelType;
  	typedef itk::RGBPixel<unsigned char>      RGBPixelType;
  	typedef itk::Image< InternalPixelType,  Dimension >  InternalImageType;
  	typedef itk::Image< RGBPixelType,       Dimension >  RGBImageType;
//   	typedef  itk::ImageFileWriter< RGBImageType  >        WriterType;
 	typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> GradientMagnitudeFilterType;
  	typedef  itk::WatershedImageFilter< ImageType > WatershedFilterType;
  	typedef itk::Functor::ScalarToRGBPixelFunctor< unsigned long> ColorMapFunctorType;
  	typedef WatershedFilterType::OutputImageType  LabeledImageType;
//   	typedef itk::UnaryFunctorImageFilter< LabeledImageType,RGBImageType,ColorMapFunctorType > ColorMapFilterType;

 typedef itk::ImageToVTKImageFilter<LabeledImageType> ConnectorType;

 GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();
 	magnitudeFilter->SetInput(reader->GetOutput());

  	WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
  	watershedFilter->SetInput( magnitudeFilter->GetOutput() );
  	watershedFilter->SetThreshold(this->sliderThresholdWatershed->value());
  	watershedFilter->SetLevel(this->sliderLevelWatershed->value());

 ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
 colorMapFilter->SetInput(  watershedFilter->GetOutput() );
  
    	WriterType::Pointer writer = WriterType::New();
   	writer->SetInput( colorMapFilter->GetOutput() );
    	writer->SetFileName("abc.tiff" );
   	writer->Update();

 ConnectorType::Pointer connector = ConnectorType::New();
 connector->SetInput( colorMapFilter->GetOutput());

Thank you very much.

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100106/cdc7966f/attachment.htm>


More information about the Insight-users mailing list