<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hello!<br><br>What you have about connection ITK to VTK said, I have made. But the result is still a 2D image not 3D. How do I change my code so I get 3D image with colors?
<br> <br>My result:
<br><span> <a target="_blank" href="http://img246.imageshack.us/my.php?image=watershed.jpg">http://img246.imageshack.us/my.php?image=watershed.jpg</a></span><br> <br>My goal: <br><span><a target="_blank" href="http://www.cs.uni-paderborn.de/fileadmin/Informatik/AG-Domik/bachelor_thesis/bolte/coronary_watershed.jpeg">http://www.cs.uni-paderborn.de/fileadmin/Informatik/AG-Domik/bachelor_thesis/bolte/coronary_watershed.jpeg</a></span><br>
<br> <br>Sorry, I am new with ITK.<br><br><br>My codes:<br><br><br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 3;<br><br> typedef itk::OrientedImage< PixelType, Dimension > ImageType;<br> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();<br><br> typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer dicomIO = ImageIOType::New();<br> <br> reader->SetImageIO( dicomIO );<br><br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br><br> nameGenerator->SetUseSeriesDetails( true );<br> nameGenerator->AddSeriesRestriction("0008|0021" );<br><br> nameGenerator->SetDirectory(
selectedDirectory);<br><br> typedef std::vector< std::string > SeriesIdContainer;<br> <br> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br> <br> SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br> while( seriesItr != seriesEnd )<br> {<br> seriesItr++;<br> }<br><br> std::string seriesIdentifier;<br><br> seriesIdentifier = seriesUID.begin()->c_str();<br><br> typedef std::vector< std::string > FileNamesContainer;<br> FileNamesContainer fileNames;<br><br> fileNames =
nameGenerator->GetFileNames( seriesIdentifier );<br><br> reader->SetFileNames( fileNames );<br> reader->Update();<br><br><br><br> typedef float InternalPixelType;<br> typedef itk::RGBPixel<unsigned char> RGBPixelType;<br> typedef itk::Image< RGBPixelType, Dimension > RGBImageType;<br>// typedef itk::ImageFileWriter< RGBImageType > WriterType;<br> typedef itk::WatershedImageFilter< ImageType > WatershedFilterType;<br>// typedef itk::Functor::ScalarToRGBPixelFunctor< unsigned long> ColorMapFunctorType;<br> typedef WatershedFilterType::OutputImageType LabeledImageType;<br>// typedef itk::UnaryFunctorImageFilter< LabeledImageType,RGBImageType,ColorMapFunctorType >
ColorMapFilterType;<br> typedef itk::ImageToVTKImageFilter <LabeledImageType> ConnectorType;<br>// typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> GradientMagnitudeFilterType;<br> <br>// GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();<br>// magnitudeFilter->SetInput(reader->GetOutput());<br><br> WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br> watershedFilter->SetInput( reader->GetOutput() );<br><br> watershedFilter->SetLevel(this->sliderLevelWatershed->value());<br> watershedFilter->SetThreshold(this->sliderLevelWatershed->value());<br><br>// ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>// colorMapFilter->SetInput( watershedFilter->GetOutput()
);<br><br> this->displayImage3D->show();<br> this->displayImage3D->redraw();<br><br> ConnectorType::Pointer connector = ConnectorType::New();<br> connector->SetInput(watershedFilter->GetOutput());<br><br><br> vtkImageShiftScale *shift = vtkImageShiftScale::New();<br> shift->SetInput(connector->GetOutput());<br> shift->SetOutputScalarTypeToUnsignedChar();<br><br><br> vtkImageActor* actor = vtkImageActor::New();<br> actor->SetInput(shift->GetOutput());<br><br> camera3D = vtkCamera::New();<br> camera3D->SetViewUp(0, 0, -1);<br> camera3D->SetPosition(0, 1, 0);<br> camera3D->SetFocalPoint(0, 0, 0);<br>
camera3D->ComputeViewPlaneNormal();<br> camera3D->Azimuth(20);<br><br> renderer3DWaterShed = vtkRenderer::New();<br> renderWindow3DWaterShed = vtkRenderWindow::New();<br> renderWindow3DWaterShed->AddRenderer(renderer3DWaterShed);<br><br> displayImage3D->SetRenderWindow(renderWindow3DWaterShed);<br>// displayImage3D->SetInteractorStyle(mode3DWaterShed);<br> displayImage3D->Initialize();<br><br> renderer3DWaterShed->AddActor(actor);<br> renderer3DWaterShed->SetActiveCamera(camera3D);<br> renderer3DWaterShed->ResetCamera();<br> camera3D->Dolly(1.3);<br>
renderer3DWaterShed->ResetCameraClippingRange();<br> renderer3DWaterShed->Render();<br><br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">Von:</span></b> Luis Ibanez <luis.ibanez@kitware.com><br><b><span style="font-weight: bold;">An:</span></b> ahmet mehmet <nasil122002@yahoo.de><br><b><span style="font-weight: bold;">CC:</span></b> vtk-developers@vtk.org; insight-users@itk.org; vtkusers@vtk.org<br><b><span style="font-weight: bold;">Gesendet:</span></b> Dienstag, den 28. April 2009, 18:53:48 Uhr<br><b><span style="font-weight: bold;">Betreff:</span></b> Re: [Insight-users] ITK to VTK 3D WatershedImageFilter<br></font><br><br><br>You are declaring an ITK+VTK connector of type:<br><br> typedef
itk::ImageToVTKImageFilter <ImageType> ConnectorType;<br><br>where ImageType is given by<br><br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 3;<br> typedef itk::OrientedImage< PixelType, Dimension > ImageType;<br><br><br>but you are connecting an image of RGB pixels to it.<br>(instead of the image of unsigned char that you promised).<br><br><br>What you may want to do is to remove the ITK Coloring filter,<br>and to pass the image of labels (the output of the watershed)<br>directly to VTK.<br><br>Note that then the ITK+VTK connector, should be of type:<br><br> itk::ImageToVTKImageFilter < LabeledImageType ><br><br><br><br> Regards,<br><br><br> Luis<br><br><br>------------------<br>ahmet mehmet wrote:<br>> Hello!<br>> 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. <br>> /home/hno4d/Desktop/MIRCIT/MIRCIT.cpp: In member function »virtual void MIRCIT::imageDisplayingWatershed()«:<br>> /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>*)«<br>> /home/hno4d/Desktop/MIRCIT/itkImageToVTKImageFilter.txx:79: Anmerkung: Kandidaten sind: void itk::ImageToVTKImageFilter<TInputImage>::SetInput(const TInputImage*) [with TInputImage = itk::OrientedImage<unsigned char, 3u>]<br>> make[2]: *** [CMakeFiles/MIRCIT.dir/MIRCIT.o] Fehler 1<br>> make[1]: *** [CMakeFiles/MIRCIT.dir/all] Fehler 2<br>> make: *** [all] Fehler 2<br>> <br>> How can I use my code with the following ITK VTK connection?<br>> My code:<br>>
<br>> typedef unsigned char PixelType;<br>> const unsigned int Dimension = 3;<br>> <br>> typedef itk::OrientedImage< PixelType, Dimension > ImageType;<br>> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>> <br>> ReaderType::Pointer reader = ReaderType::New();<br>> <br>> typedef itk::GDCMImageIO ImageIOType;<br>> ImageIOType::Pointer dicomIO = ImageIOType::New();<br>> <br>> reader->SetImageIO( dicomIO );<br>> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br>> nameGenerator->SetUseSeriesDetails( true );<br>> nameGenerator->AddSeriesRestriction("0008|0021" );<br>> nameGenerator->SetDirectory( selectedDirectory);<br>> typedef std::vector< std::string > SeriesIdContainer;<br>> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br>>
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br>> while( seriesItr != seriesEnd )<br>> {<br>> seriesItr++;<br>> }<br>> <br>> std::string seriesIdentifier;<br>> seriesIdentifier = seriesUID.begin()->c_str();<br>> <br>> typedef std::vector< std::string > FileNamesContainer;<br>> FileNamesContainer fileNames;<br>> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br>> <br>> reader->SetFileNames( fileNames );<br>> reader->Update();<br>> <br>> typedef float InternalPixelType;<br>> typedef itk::RGBPixel<unsigned char> RGBPixelType;<br>> typedef itk::Image< RGBPixelType, Dimension > RGBImageType;<br>> // typedef itk::ImageFileWriter< RGBImageType > WriterType;<br>> typedef itk::WatershedImageFilter< ImageType > WatershedFilterType;<br>> typedef
itk::Functor::ScalarToRGBPixelFunctor< unsigned long> ColorMapFunctorType;<br>> typedef WatershedFilterType::OutputImageType LabeledImageType;<br>> typedef itk::UnaryFunctorImageFilter< LabeledImageType,RGBImageType,ColorMapFunctorType > ColorMapFilterType;<br>> typedef itk::ImageToVTKImageFilter <ImageType> ConnectorType;<br>> typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> GradientMagnitudeFilterType;<br>> <br>> GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();<br>> magnitudeFilter->SetInput(reader->GetOutput());<br>> <br>> WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br>> watershedFilter->SetInput( magnitudeFilter->GetOutput() );<br>> watershedFilter->SetThreshold(this->sliderLevelWatershed->value());<br>>
watershedFilter->SetLevel(this->sliderThresholdWatershed->value());<br>> <br>> ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>> colorMapFilter->SetInput( watershedFilter->GetOutput() );<br>> <br>> ConnectorType::Pointer connector = ConnectorType::New();<br>> connector->SetInput(colorMapFilter->GetOutput());<br>> <br>> vtkImageActor* actor = vtkImageActor::New();<br>> actor->SetInput(connector->GetOutput());<br>> <br>> vtkInteractorStyleImage * interactorStyle = vtkInteractorStyleImage::New();<br>> <br>> vtkRenderer* renderer = vtkRenderer::New();<br>> vtkRenderWindow* renWin = vtkRenderWindow::New();<br>> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br>> <br>> renWin->SetSize(500, 500);<br>> renWin->AddRenderer(renderer);<br>> iren->SetRenderWindow(renWin);<br>> iren->SetInteractorStyle( interactorStyle
);<br>> renderer->AddActor(actor);<br>> <br>> renWin->Render();<br>> iren->Start();<br>> <br>> Thank you!<br>> <br>> <br>> <br>> ------------------------------------------------------------------------<br>> <br>> _____________________________________<br><span>> Powered by <a target="_blank" href="http://www.kitware.com">www.kitware.com</a></span><br>> <br>> Visit other Kitware open-source projects at<br>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>> <br>> Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>> <br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.itk.org/mailman/listinfo/insight-users"
target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br></div></div></div><br>
</body></html>