[vtkusers] VolumeRendering Problem

Yusuf OEZBEK nasil122002 at yahoo.de
Wed Jun 3 06:26:53 EDT 2009


Hello! 

I wanted my watershed-segmentation result (from ITK) through vtkVolumeProMapper 3D So make a 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 and CMakeList:

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();
}
project (MIRCIT)

#
#FIND ITK
#
FIND_PACKAGE(ITK)
IF (USE_ITK_FILE)
  INCLUDE (${USE_ITK_FILE})
ELSE (USE_ITK_FILE)
  MESSAGE( FATAL_ERROR "This application requires ITK. One of these components is missing. Please verify configuration")
ENDIF (USE_ITK_FILE)


#
#FIND VTK
#
FIND_PACKAGE(VTK)
IF(USE_VTK_FILE)
 INCLUDE(${USE_VTK_FILE})
ELSE (USE_VTK_FILE)
 MESSAGE( FATAL_ERROR "This app. req. VTK. One of these comp. is. missing. Please verify conf.")
ENDIF (USE_VTK_FILE)


#
#FIND FLTK
#
FIND_PACKAGE(FLTK)
  IF (FLTK_FOUND)
  INCLUDE_DIRECTORIES (${FLTK_INCLUDE_DIR})
  LINK_LIBRARIES( ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES} )
  ELSE (FLTK_FOUND)
  MESSAGE( FATAL_ERROR "This application requires FLTK. One of these components is missing. Please verify configuration")
ENDIF (FLTK_FOUND)

add_executable (MIRCIT main.cpp MIRCIT.cpp MIRCIT.h MIRCITGui.cpp MIRCITGui.h info.cpp vtkFlRenderWindowInteractor.cpp)


TARGET_LINK_LIBRARIES(MIRCIT vtkCommon vtkexpat vtkFiltering vtkfreetype vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO vtkjpeg vtkpng vtkVolumeRendering vtkRendering vtktiff vtkzlib ITKBasicFilters ITKCommon ITKIO ${ITK_LIBRARIES})


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090603/412e25e4/attachment.htm>


More information about the vtkusers mailing list