<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:"Times New Roman", 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 rel="nofollow" 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 rel="nofollow" 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 style="font-family:times new roman, new york, times, serif;font-size:12pt;"><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 rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</A></SPAN><BR>> <BR>> Visit other Kitware open-source projects at<BR>> <A rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</A><BR>> <BR>> Please keep messages on-topic and check the ITK FAQ at: <A rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</A><BR>> <BR>> Follow this link to subscribe/unsubscribe:<BR>> <A rel="nofollow" target="_blank"
href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</A><BR></DIV></DIV></DIV><BR>
</DIV></div><br>
</body></html>