<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&nbsp; 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?&nbsp;
<br>&nbsp;<br>My result:
<br><span>&nbsp;<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>&nbsp;<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>
&nbsp;<br>&nbsp;<br>Sorry, I am new with ITK.<br><br><br>My codes:<br><br><br>&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp; PixelType;<br>&nbsp; const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dimension = 3;<br><br>&nbsp; typedef itk::OrientedImage&lt; PixelType, Dimension &gt;&nbsp;&nbsp;&nbsp; ImageType;<br>&nbsp; typedef itk::ImageSeriesReader&lt; ImageType &gt;&nbsp;&nbsp; ReaderType;<br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br><br>&nbsp; typedef itk::GDCMImageIO&nbsp;&nbsp;&nbsp;&nbsp; ImageIOType;<br>&nbsp; ImageIOType::Pointer dicomIO = ImageIOType::New();<br>&nbsp; <br>&nbsp; reader-&gt;SetImageIO( dicomIO );<br><br>&nbsp; typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>&nbsp; NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br><br>&nbsp; nameGenerator-&gt;SetUseSeriesDetails( true );<br>&nbsp; nameGenerator-&gt;AddSeriesRestriction("0008|0021" );<br><br>&nbsp; nameGenerator-&gt;SetDirectory(
 selectedDirectory);<br><br>&nbsp; typedef std::vector&lt; std::string &gt;&nbsp;&nbsp;&nbsp; SeriesIdContainer;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; const SeriesIdContainer &amp; seriesUID = nameGenerator-&gt;GetSeriesUIDs();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>&nbsp;&nbsp;&nbsp; SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br>&nbsp;&nbsp;&nbsp; while( seriesItr != seriesEnd )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; seriesItr++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::string seriesIdentifier;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; seriesIdentifier = seriesUID.begin()-&gt;c_str();<br><br>&nbsp;&nbsp; typedef std::vector&lt; std::string &gt;&nbsp;&nbsp; FileNamesContainer;<br>&nbsp;&nbsp;&nbsp; FileNamesContainer fileNames;<br><br>&nbsp;&nbsp;&nbsp; fileNames =
 nameGenerator-&gt;GetFileNames( seriesIdentifier );<br><br>&nbsp;&nbsp;&nbsp; reader-&gt;SetFileNames( fileNames );<br>&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br><br><br><br>&nbsp; typedef float&nbsp;&nbsp;&nbsp;&nbsp; InternalPixelType;<br>&nbsp;&nbsp; typedef itk::RGBPixel&lt;unsigned char&gt;&nbsp; RGBPixelType;<br>&nbsp;&nbsp; typedef itk::Image&lt; RGBPixelType, Dimension &gt;&nbsp; RGBImageType;<br>// typedef&nbsp; itk::ImageFileWriter&lt; RGBImageType&nbsp; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WriterType;<br>&nbsp;&nbsp; typedef&nbsp; itk::WatershedImageFilter&lt; ImageType &gt; WatershedFilterType;<br>// typedef itk::Functor::ScalarToRGBPixelFunctor&lt; unsigned long&gt; ColorMapFunctorType;<br>&nbsp;&nbsp; typedef WatershedFilterType::OutputImageType&nbsp; LabeledImageType;<br>// typedef itk::UnaryFunctorImageFilter&lt; LabeledImageType,RGBImageType,ColorMapFunctorType &gt;&nbsp;&nbsp;&nbsp;&nbsp;
 ColorMapFilterType;<br>&nbsp;&nbsp;&nbsp; typedef itk::ImageToVTKImageFilter &lt;LabeledImageType&gt; ConnectorType;<br>//&nbsp; typedef itk::GradientMagnitudeImageFilter&lt;ImageType, ImageType&gt; GradientMagnitudeFilterType;<br>&nbsp;<br>//&nbsp; GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();<br>//&nbsp; magnitudeFilter-&gt;SetInput(reader-&gt;GetOutput());<br><br>&nbsp;&nbsp; WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br>&nbsp;&nbsp; watershedFilter-&gt;SetInput( reader-&gt;GetOutput() );<br><br>&nbsp;&nbsp; watershedFilter-&gt;SetLevel(this-&gt;sliderLevelWatershed-&gt;value());<br>&nbsp;&nbsp; watershedFilter-&gt;SetThreshold(this-&gt;sliderLevelWatershed-&gt;value());<br><br>//&nbsp;&nbsp; ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>//&nbsp;&nbsp; colorMapFilter-&gt;SetInput(&nbsp; watershedFilter-&gt;GetOutput()
 );<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this-&gt;displayImage3D-&gt;show();<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this-&gt;displayImage3D-&gt;redraw();<br><br>&nbsp;&nbsp;&nbsp; ConnectorType::Pointer connector = ConnectorType::New();<br>&nbsp;&nbsp;&nbsp; connector-&gt;SetInput(watershedFilter-&gt;GetOutput());<br><br><br>&nbsp;&nbsp;&nbsp; vtkImageShiftScale *shift = vtkImageShiftScale::New();<br>&nbsp;&nbsp;&nbsp; shift-&gt;SetInput(connector-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; shift-&gt;SetOutputScalarTypeToUnsignedChar();<br><br><br>&nbsp;&nbsp;&nbsp; vtkImageActor* actor = vtkImageActor::New();<br>&nbsp;&nbsp;&nbsp; actor-&gt;SetInput(shift-&gt;GetOutput());<br><br>&nbsp; &nbsp;&nbsp; camera3D = vtkCamera::New();<br>&nbsp;&nbsp;&nbsp;&nbsp; camera3D-&gt;SetViewUp(0, 0, -1);<br>&nbsp;&nbsp;&nbsp;&nbsp; camera3D-&gt;SetPosition(0, 1, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp; camera3D-&gt;SetFocalPoint(0, 0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;
 camera3D-&gt;ComputeViewPlaneNormal();<br>&nbsp;&nbsp;&nbsp;&nbsp; camera3D-&gt;Azimuth(20);<br><br>&nbsp;&nbsp;&nbsp;&nbsp; renderer3DWaterShed = vtkRenderer::New();<br>&nbsp;&nbsp;&nbsp;&nbsp; renderWindow3DWaterShed = vtkRenderWindow::New();<br>&nbsp;&nbsp;&nbsp;&nbsp; renderWindow3DWaterShed-&gt;AddRenderer(renderer3DWaterShed);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; displayImage3D-&gt;SetRenderWindow(renderWindow3DWaterShed);<br>//&nbsp; &nbsp;&nbsp;&nbsp; displayImage3D-&gt;SetInteractorStyle(mode3DWaterShed);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; displayImage3D-&gt;Initialize();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer3DWaterShed-&gt;AddActor(actor);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderer3DWaterShed-&gt;SetActiveCamera(camera3D);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderer3DWaterShed-&gt;ResetCamera();<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; camera3D-&gt;Dolly(1.3);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 renderer3DWaterShed-&gt;ResetCameraClippingRange();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer3DWaterShed-&gt;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 &lt;luis.ibanez@kitware.com&gt;<br><b><span style="font-weight: bold;">An:</span></b> ahmet mehmet &lt;nasil122002@yahoo.de&gt;<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>&nbsp; typedef
 itk::ImageToVTKImageFilter &lt;ImageType&gt; ConnectorType;<br><br>where ImageType is given by<br><br>&nbsp; typedef unsigned char PixelType;<br>&nbsp; const unsigned int Dimension = 3;<br>&nbsp; typedef itk::OrientedImage&lt; PixelType, Dimension &gt; 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>&nbsp; &nbsp; itk::ImageToVTKImageFilter &lt; LabeledImageType &gt;<br><br><br><br>&nbsp; Regards,<br><br><br>&nbsp; &nbsp; &nbsp; Luis<br><br><br>------------------<br>ahmet mehmet wrote:<br>&gt; Hello!<br>&gt;&nbsp; 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.&nbsp;  <br>&gt; /home/hno4d/Desktop/MIRCIT/MIRCIT.cpp: In member function »virtual void MIRCIT::imageDisplayingWatershed()«:<br>&gt; /home/hno4d/Desktop/MIRCIT/MIRCIT.cpp:1719: Fehler: keine passende Funktion für Aufruf von »itk::ImageToVTKImageFilter&lt;itk::OrientedImage&lt;unsigned char, 3u&gt;&nbsp; &gt;::SetInput(itk::Image&lt;itk::RGBPixel&lt;unsigned char&gt;, 3u&gt;*)«<br>&gt; /home/hno4d/Desktop/MIRCIT/itkImageToVTKImageFilter.txx:79: Anmerkung: Kandidaten sind: void itk::ImageToVTKImageFilter&lt;TInputImage&gt;::SetInput(const TInputImage*) [with TInputImage = itk::OrientedImage&lt;unsigned char, 3u&gt;]<br>&gt; make[2]: *** [CMakeFiles/MIRCIT.dir/MIRCIT.o] Fehler 1<br>&gt; make[1]: *** [CMakeFiles/MIRCIT.dir/all] Fehler 2<br>&gt; make: *** [all] Fehler 2<br>&gt; <br>&gt;&nbsp;  How can I use my code with the following ITK VTK connection?<br>&gt;&nbsp;  My code:<br>&gt;&nbsp; 
 <br>&gt; typedef unsigned char PixelType;<br>&gt; const unsigned int Dimension = 3;<br>&gt; <br>&gt; typedef itk::OrientedImage&lt; PixelType, Dimension &gt; ImageType;<br>&gt; typedef itk::ImageSeriesReader&lt; ImageType &gt; ReaderType;<br>&gt; <br>&gt; ReaderType::Pointer reader = ReaderType::New();<br>&gt; <br>&gt; typedef itk::GDCMImageIO ImageIOType;<br>&gt; ImageIOType::Pointer dicomIO = ImageIOType::New();<br>&gt; <br>&gt; reader-&gt;SetImageIO( dicomIO );<br>&gt; typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>&gt;&nbsp; NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br>&gt; nameGenerator-&gt;SetUseSeriesDetails( true );<br>&gt; nameGenerator-&gt;AddSeriesRestriction("0008|0021" );<br>&gt; nameGenerator-&gt;SetDirectory( selectedDirectory);<br>&gt;&nbsp; typedef std::vector&lt; std::string &gt; SeriesIdContainer;<br>&gt; const SeriesIdContainer &amp; seriesUID = nameGenerator-&gt;GetSeriesUIDs();<br>&gt;
 SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>&gt; SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br>&gt; while( seriesItr != seriesEnd )<br>&gt; {<br>&gt; seriesItr++;<br>&gt; }<br>&gt; <br>&gt; std::string seriesIdentifier;<br>&gt; seriesIdentifier = seriesUID.begin()-&gt;c_str();<br>&gt; <br>&gt; typedef std::vector&lt; std::string &gt; FileNamesContainer;<br>&gt; FileNamesContainer fileNames;<br>&gt; fileNames = nameGenerator-&gt;GetFileNames( seriesIdentifier );<br>&gt; <br>&gt; reader-&gt;SetFileNames( fileNames );<br>&gt; reader-&gt;Update();<br>&gt; <br>&gt; typedef float InternalPixelType;<br>&gt; typedef itk::RGBPixel&lt;unsigned char&gt; RGBPixelType;<br>&gt; typedef itk::Image&lt; RGBPixelType, Dimension &gt; RGBImageType;<br>&gt; // typedef itk::ImageFileWriter&lt; RGBImageType &gt; WriterType;<br>&gt; typedef itk::WatershedImageFilter&lt; ImageType &gt; WatershedFilterType;<br>&gt; typedef
 itk::Functor::ScalarToRGBPixelFunctor&lt; unsigned long&gt; ColorMapFunctorType;<br>&gt; typedef WatershedFilterType::OutputImageType LabeledImageType;<br>&gt; typedef itk::UnaryFunctorImageFilter&lt; LabeledImageType,RGBImageType,ColorMapFunctorType &gt; ColorMapFilterType;<br>&gt; typedef itk::ImageToVTKImageFilter &lt;ImageType&gt; ConnectorType;<br>&gt; typedef itk::GradientMagnitudeImageFilter&lt;ImageType, ImageType&gt; GradientMagnitudeFilterType;<br>&gt; <br>&gt;&nbsp; GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();<br>&gt; magnitudeFilter-&gt;SetInput(reader-&gt;GetOutput());<br>&gt; <br>&gt;&nbsp; WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br>&gt; watershedFilter-&gt;SetInput( magnitudeFilter-&gt;GetOutput() );<br>&gt; watershedFilter-&gt;SetThreshold(this-&gt;sliderLevelWatershed-&gt;value());<br>&gt;
 watershedFilter-&gt;SetLevel(this-&gt;sliderThresholdWatershed-&gt;value());<br>&gt; <br>&gt; ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>&gt; colorMapFilter-&gt;SetInput( watershedFilter-&gt;GetOutput() );<br>&gt; <br>&gt; ConnectorType::Pointer connector = ConnectorType::New();<br>&gt; connector-&gt;SetInput(colorMapFilter-&gt;GetOutput());<br>&gt; <br>&gt; vtkImageActor* actor = vtkImageActor::New();<br>&gt; actor-&gt;SetInput(connector-&gt;GetOutput());<br>&gt; <br>&gt; vtkInteractorStyleImage * interactorStyle = vtkInteractorStyleImage::New();<br>&gt; <br>&gt; vtkRenderer* renderer = vtkRenderer::New();<br>&gt; vtkRenderWindow* renWin = vtkRenderWindow::New();<br>&gt; vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br>&gt; <br>&gt; renWin-&gt;SetSize(500, 500);<br>&gt; renWin-&gt;AddRenderer(renderer);<br>&gt; iren-&gt;SetRenderWindow(renWin);<br>&gt; iren-&gt;SetInteractorStyle( interactorStyle
 );<br>&gt; renderer-&gt;AddActor(actor);<br>&gt; <br>&gt; renWin-&gt;Render();<br>&gt; iren-&gt;Start();<br>&gt; <br>&gt; Thank you!<br>&gt; <br>&gt; <br>&gt; <br>&gt; ------------------------------------------------------------------------<br>&gt; <br>&gt; _____________________________________<br><span>&gt; Powered by <a target="_blank" href="http://www.kitware.com">www.kitware.com</a></span><br>&gt; <br>&gt; Visit other Kitware open-source projects at<br>&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; <br>&gt; 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>&gt; <br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <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>