[vtkusers] VolumeRendering Problem

Yusuf OEZBEK nasil122002 at yahoo.de
Sun May 31 16:22:24 EDT 2009


Hello! 

I wanted my watershed-segmentation result (from ITK) through vtkVolumeProMapper 3D So make a 3D volume. I have used vtkVolumeProMapper and vtkVolume. But I always get the error "undefined reference to vtkVolumeProMapper". Where is my mistake? I would be glad if you can help. 

Thank you! 

My code:
void MIRCIT::imageDisplayingWatershed(){

 this->displayImage3D->show();
 this->displayImage3D->redraw();

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

  typedef itk::OrientedImage< PixelType, Dimension >    ImageType;

  typedef itk::ImageSeriesReader< ImageType >   ReaderType;
  ReaderType::Pointer reader = ReaderType::New();

  typedef itk::GDCMImageIO     ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  
  reader->SetImageIO( dicomIO );

  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

  nameGenerator->SetUseSeriesDetails( true );
  nameGenerator->AddSeriesRestriction("0008|0021" );

  nameGenerator->SetDirectory( selectedDirectory);

  typedef std::vector< std::string >    SeriesIdContainer;
    
  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();

  typedef std::vector< std::string >   FileNamesContainer;
  FileNamesContainer fileNames;

  fileNames = nameGenerator->GetFileNames( seriesIdentifier );
  reader->SetFileNames( fileNames );
  reader->Update();

  typedef float     InternalPixelType;
  typedef itk::RGBPixel<unsigned char>  RGBPixelType;
  typedef itk::Image< RGBPixelType, Dimension >  RGBImageType;
  typedef  itk::ImageFileWriter< RGBImageType  >        WriterType;
  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;
  typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> GradientMagnitudeFilterType;
 
  GradientMagnitudeFilterType::Pointer magnitudeFilter =  GradientMagnitudeFilterType::New();
  magnitudeFilter->SetInput(reader->GetOutput());

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

  ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
  colorMapFilter->SetInput(  watershedFilter->GetOutput() );

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

  vtkImageShiftScale *shift = vtkImageShiftScale::New();
  shift->SetInput(connector->GetOutput());
  shift->SetOutputScalarTypeToUnsignedChar();

  vtkVolumeProMapper *mapperb = vtkVolumeProMapper::New();
  mapperb->SetInputConnection(shift->GetOutputPort());

  vtkVolume *volumeb = vtkVolume::New();
  volumeb->SetMapper(mapperb);

  camera3D = vtkCamera::New();
  camera3D->SetViewUp(0, 0, -1);
  camera3D->SetPosition(0, 1, 0);
  camera3D->SetFocalPoint(0, 0, 0);
  camera3D->ComputeViewPlaneNormal();
  camera3D->Azimuth(20);

  renderer3DWaterShed = vtkRenderer::New();
  renderWindow3DWaterShed = vtkRenderWindow::New();
  renderWindow3DWaterShed->AddRenderer(renderer3DWaterShed);

  displayImage3D->SetRenderWindow(renderWindow3DWaterShed);
  displayImage3D->SetInteractorStyle(mode3DWaterShed);
  displayImage3D->Initialize();

  renderer3DWaterShed->AddViewProp(volumeb);
  renderer3DWaterShed->SetActiveCamera(camera3D);
  renderer3DWaterShed->ResetCamera();
  camera3D->Dolly(1.3);
  renderer3DWaterShed->ResetCameraClippingRange();
  renderer3DWaterShed->Render();

  this->displayImage3D->show();
  this->displayImage3D->redraw();

  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( colorMapFilter->GetOutput() );
  writer->SetFileName("fds.tiff" );
  writer->Update();
}


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090531/51a770eb/attachment.htm>


More information about the vtkusers mailing list