[Insight-users] ITK to VTK 3D WatershedImageFilter

ahmet mehmet nasil122002 at yahoo.de
Mon Apr 27 09:39:18 EDT 2009


Hello!

I wanted my 3D watershed segmentation combine with VTK and to show it in a VTK window. For the connection between ITK and VTK, I used itkImageToVTKImageFilter. But it gives following error. 


/home/hno4d/Desktop/MIRCIT/MIRCIT.cpp: In member function »virtual void MIRCIT::imageDisplayingWatershed()«:
/home/hno4d/Desktop/MIRCIT/MIRCIT.cpp:1719: Fehler: keine passende Funktion für Aufruf von »itk::ImageToVTKImageFilter<itk::OrientedImage<unsigned char, 3u> >::SetInput(itk::Image<itk::RGBPixel<unsigned char>, 3u>*)«
/home/hno4d/Desktop/MIRCIT/itkImageToVTKImageFilter.txx:79: Anmerkung: Kandidaten sind: void itk::ImageToVTKImageFilter<TInputImage>::SetInput(const TInputImage*) [with TInputImage = itk::OrientedImage<unsigned char, 3u>]
make[2]: *** [CMakeFiles/MIRCIT.dir/MIRCIT.o] Fehler 1
make[1]: *** [CMakeFiles/MIRCIT.dir/all] Fehler 2
make: *** [all] Fehler 2
 


How can I use my code with the following ITK VTK connection?


My code:


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 <ImageType> 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->SetThreshold(this->sliderLevelWatershed->value());
watershedFilter->SetLevel(this->sliderThresholdWatershed->value());
 
ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
colorMapFilter->SetInput( watershedFilter->GetOutput() );
 
ConnectorType::Pointer connector = ConnectorType::New();
connector->SetInput(colorMapFilter->GetOutput());
 
vtkImageActor* actor = vtkImageActor::New();
actor->SetInput(connector->GetOutput());
 
vtkInteractorStyleImage * interactorStyle = vtkInteractorStyleImage::New();
 
vtkRenderer* renderer = vtkRenderer::New();
vtkRenderWindow* renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
 
renWin->SetSize(500, 500);
renWin->AddRenderer(renderer);
iren->SetRenderWindow(renWin);
iren->SetInteractorStyle( interactorStyle );
renderer->AddActor(actor);
 
renWin->Render();
iren->Start();
 
 
Thank you!


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090427/ec90bf5f/attachment.htm>


More information about the Insight-users mailing list