[Insight-users] watershed segmentation without RGB?

Laurent Mundeleer lmundele at ulb.ac.be
Fri, 30 Apr 2004 18:29:24 +0200


This is a multi-part message in MIME format.
--------------020709020908070409070801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Josh,
I've just an abnormal termination, without any other message at the 
first line of tumorFilterITKExec()...

Laurent
Joshua Cates wrote:

>Hi Laurent,
>
>What is the error that you are getting?
>
>Josh.
>
>______________________________
> Josh Cates			
> Scientific Computing and Imaging Institute
> University of Utah
> (801) 587-7697
> http://www.sci.utah.edu/~cates
>
>
>On Fri, 30 Apr 2004, Laurent Mundeleer wrote:
>
>  
>
>>Hi James,
>>
>>I've tried to convert the WatershedSegmentation1.cxx to grayscale 
>>images, but I still have problems (abnormal termination).
>>Here's my code :
>>--------------------
>>tumorFilterITK.h
>>--------------------
>>#ifndef tumorFilterITK_H
>>#define tumorFilterITK_H
>>
>>
>>#include <itkVTKImageExport.h>
>>#include <itkVTKImageImport.h>
>>#include <vtkImageImport.h>
>>#include <vtkImageExport.h>
>>
>>#include <itkGradientAnisotropicDiffusionImageFilter.h>
>>#include <itkGradientMagnitudeImageFilter.h>
>>#include <itkWatershedImageFilter.h>
>>#include <itkCastImageFilter.h>
>>
>>class tumorFilterITK
>>{
>>
>>public:
>>
>>    typedef short pixelType;
>>
>>    typedef itk::Image<pixelType, 3> ImageType;
>>    typedef itk::Image<unsigned long, 3> ImageTypeOut;
>>
>>    typedef itk::VTKImageImport<ImageType> ImageImportType;
>>    typedef itk::VTKImageExport<ImageType> ImageExportType;
>> 
>>    typedef itk::CastImageFilter<ImageTypeOut, ImageType> CastFilterType;
>>
>>    typedef itk::GradientAnisotropicDiffusionImageFilter<ImageType,    
>>ImageType>  DiffusionFilterType;
>>    typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> 
>>GradientMagnitudeFilterType;
>>    typedef itk::WatershedImageFilter<ImageType> WatershedFilterType;
>>
>>    tumorFilterITK(vtkImageImport*, vtkImageExport*);
>>    void tumorFilterITKExec();
>>
>>private:
>>
>>    ImageImportType::Pointer itkImporter;
>>    ImageExportType::Pointer itkExporter;
>>
>>    CastFilterType::Pointer caster;
>>
>>    DiffusionFilterType::Pointer diffusion;
>>    GradientMagnitudeFilterType::Pointer gradient;
>>    WatershedFilterType::Pointer watershed;
>>};
>>
>>#endif
>>--------------------------------------------
>>--------------------
>>tumorFilterITK.cpp
>>--------------------
>>
>>#include "tumorFilterITK.h"
>>
>>/// connexion de ITK a VTK
>>template <typename ITK_Exporter, typename VTK_Importer>
>>void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
>>{
>>  
>>importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
>>  
>>importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
>>  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
>>  importer->SetSpacingCallback(exporter->GetSpacingCallback());
>>  importer->SetOriginCallback(exporter->GetOriginCallback());
>>  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
>>  
>>importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
>>  
>>importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
>>  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
>>  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
>>  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
>>  importer->SetCallbackUserData(exporter->GetCallbackUserData());
>>}
>>
>>//-----------------------------------------------------------------
>>
>>/// connexion de VTK a ITK
>>template <typename VTK_Exporter, typename ITK_Importer>
>>void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer importer)
>>{
>>  
>>importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
>>  
>>importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
>>  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
>>  importer->SetSpacingCallback(exporter->GetSpacingCallback());
>>  importer->SetOriginCallback(exporter->GetOriginCallback());
>>  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
>>  
>>importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
>>  
>>importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
>>  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
>>  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
>>  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
>>  importer->SetCallbackUserData(exporter->GetCallbackUserData());
>>}
>>
>>//-----------------------------------------------------------------
>>
>>///contructeur initialisant le pipeline ITK
>>tumorFilterITK::tumorFilterITK(vtkImageImport* vtkImporter, 
>>vtkImageExport *vtkExporter)
>>{       
>>    itkImporter = ImageImportType::New();
>>    itkExporter = ImageExportType::New();
>>
>>//    itkExporter->SetInput(itkImporter->GetOutput());
>>    diffusion = DiffusionFilterType::New();
>>    gradient = GradientMagnitudeFilterType::New();
>>    caster = CastFilterType::New();
>>
>>    watershed = WatershedFilterType::New();
>>   
>>    ConnectPipelines(vtkExporter, itkImporter);
>>    ConnectPipelines(itkExporter, vtkImporter);   
>>
>>    tumorFilterITKExec();
>>}
>>
>>//-----------------------------------------------------------------
>>
>>/// execution du filtre de detection de tumeurs
>>void tumorFilterITK::tumorFilterITKExec()
>>{
>>
>>     //inputImage outputImage conductanceTerm diffusionIterations 
>>lowerThreshold outputScaleLevel gradientMode " << std::endl;
>>
>>    diffusion->SetNumberOfIterations( 5 ); // 5 typically
>>    diffusion->SetConductanceParameter( 3.0 ); // 3.0 typically
>>    diffusion->SetTimeStep(0.125);
>>
>>    watershed->SetLevel( 0.001 ); // 0->1 en %
>>    watershed->SetThreshold( 0.001 ); // 0->1 en %
>>
>>    diffusion->SetInput(itkImporter->GetOutput());
>>    gradient->SetInput(diffusion->GetOutput());
>>    watershed->SetInput(gradient->GetOutput());
>>
>>    try
>>    {
>>    watershed->Update();
>>    }
>>    catch (itk::ExceptionObject &e)
>>    {
>>    std::cerr << e << std::endl;
>>    }
>>    caster->SetInput(watershed->GetOutput());
>>    itkExporter->SetInput(caster->GetOutput());
>>}
>>
>>------------------------------------
>>
>>Maybe can you help me?
>>Thanks again,
>>
>>Regards,
>>
>>Laurent
>>
>>
>>
>>Miller, James V (Research) wrote:
>>
>>    
>>
>>>Watershed can be run on grayscale images.  The example
>>>(WatershedSegmentation1.cxx) is set up to process RGB pixels. But you can
>>>easily run watershed on a grayscale image.
>>>
>>>You'll want to create a similar program to WatershedSegmentation1.cxx that
>>>reads a scalar image, produces a gradient magnitude image
>>>(GradientMagnitudeImageFilter or RecursiveGradientMagnitudeImageFilter), and
>>>runs watershed on the gradient magnitude image.
>>>
>>>So you just need to change the pixel type, delete the word "Vector" from any
>>>class type in example, and change the CastType to a CastImageFilter that
>>>converts a scalar image into an image of floating point pixels (alternative,
>>>you can remove the cast filter altogether and have the reader return an
>>>image of floating point pixels.  Here is a quick stab at it (haven't tried
>>>to compile it....)
>>>
>>>#ifdef _MSC_VER
>>>#pragma warning ( disable : 4786 )
>>>#endif
>>>
>>>#include <iostream>
>>>
>>>#include "itkGradientAnisotropicDiffusionImageFilter.h"
>>>#include "itkGradientMagnitudeImageFilter.h"
>>>#include "itkWatershedImageFilter.h"
>>>
>>>#include "itkImageFileReader.h"
>>>#include "itkImageFileWriter.h"
>>>#include "itkUnaryFunctorImageFilter.h"
>>>#include "itkScalarToRGBPixelFunctor.h"
>>>
>>>int main( int argc, char *argv[] )
>>>{
>>> if (argc < 8 )
>>>   {
>>>   std::cerr << "Missing Parameters " << std::endl;
>>>   std::cerr << "Usage: " << argv[0];
>>>   std::cerr << " inputImage outputImage conductanceTerm
>>>diffusionIterations lowerThreshold outputScaleLevel gradientMode " <<
>>>std::endl;
>>>   return 1;
>>>   }
>>> 
>>> typedef itk::RGBPixel<unsigned char>   RGBPixelType;
>>> typedef itk::Image<RGBPixelType, 2>    RGBImageType;
>>> typedef itk::Image<unsigned long, 2>   LabeledImageType;
>>> typedef itk::Image<float, 2>           ScalarImageType;
>>>
>>> typedef itk::ImageFileReader<ScalarImageType> FileReaderType;
>>> typedef itk::GradientAnisotropicDiffusionImageFilter<ScalarImageType,
>>>   ScalarImageType>  DiffusionFilterType;
>>> typedef itk::GradientMagnitudeImageFilter<ScalarImageType>
>>>   ScalarMagnitudeFilterType; 
>>> typedef itk::WatershedImageFilter<ScalarImageType> WatershedFilterType;
>>> // Software Guide : EndCodeSnippet
>>>
>>> typedef itk::ImageFileWriter<RGBImageType> FileWriterType;
>>>
>>> FileReaderType::Pointer reader = FileReaderType::New();
>>> reader->SetFileName(argv[1]);
>>> 
>>> DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
>>> diffusion->SetNumberOfIterations( atoi(argv[4]) );
>>> diffusion->SetConductanceParameter( atof(argv[3]) );
>>> diffusion->SetTimeStep(0.125);
>>>
>>>
>>> GradientMagnitudeFilterType::Pointer gradient =
>>>GradientMagnitudeFilterType::New();
>>> gradient->SetUsePrincipleComponents(atoi(argv[7]));
>>>
>>>
>>> WatershedFilterType::Pointer watershed = WatershedFilterType::New();
>>> watershed->SetLevel( atof(argv[6]) );
>>> watershed->SetThreshold( atof(argv[5]) );
>>>
>>>
>>> typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long>
>>>   ColorMapFunctorType;
>>> typedef itk::UnaryFunctorImageFilter<LabeledImageType,
>>>   RGBImageType, ColorMapFunctorType> ColorMapFilterType;
>>> ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
>>> 
>>> FileWriterType::Pointer writer = FileWriterType::New();
>>> writer->SetFileName(argv[2]);
>>>
>>> diffusion->SetInput(reader->GetOutput());
>>> gradient->SetInput(diffusion->GetOutput());
>>> watershed->SetInput(gradient->GetOutput());
>>> colormapper->SetInput(watershed->GetOutput());
>>> writer->SetInput(colormapper->GetOutput());
>>>
>>> try 
>>>   {
>>>   writer->Update();
>>>   }
>>> catch (itk::ExceptionObject &e)
>>>   {
>>>   std::cerr << e << std::endl;
>>>   }
>>>   
>>> return 0;
>>>}
>>>
>>>
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: Laurent Mundeleer [mailto:lmundele at ulb.ac.be]
>>>Sent: Thursday, April 29, 2004 6:10 AM
>>>To: insight-users at itk.org
>>>Subject: [Insight-users] watershed segmentation without RGB?
>>>
>>>
>>>Hi all,
>>>
>>>I'd like to apply the watershed filter to CT images, is it possible? In 
>>>the documentation, it 's specified that RGB values are required...
>>>How can I do?
>>>
>>>Thanks in advance
>>>
>>>Regards,
>>>
>>>Laurent
>>>
>>> 
>>>
>>>      
>>>
>>-- 
>>********************************************
>>Laurent Mundeleer
>>Université Libre de Bruxelles (ULB)
>>Service des Systèmes Logiques et Numériques (SLN) CP165/57
>>50, Av. F.Roosevelt
>>1050 Bruxelles
>>Belgium
>>tel : ++32.2.650.22.97
>>fax : ++32.2.650.22.98
>>e-mail : lmundele at ulb.ac.be
>>********************************************
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>    
>>
>
>
>  
>

-- 
********************************************
Laurent Mundeleer
Université Libre de Bruxelles (ULB)
Service des Systèmes Logiques et Numériques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : lmundele at ulb.ac.be
********************************************


--------------020709020908070409070801
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Josh,<br>
I've just an abnormal termination, without any other message at the
first line of tumorFilterITKExec()...<br>
<br>
Laurent<br>
Joshua Cates wrote:
<blockquote
 cite="midPine.LNX.4.44.0404301020170.17353-100000 at poblano.sci.utah.edu"
 type="cite">
  <pre wrap="">Hi Laurent,

What is the error that you are getting?

Josh.

______________________________
 Josh Cates			
 Scientific Computing and Imaging Institute
 University of Utah
 (801) 587-7697
 <a class="moz-txt-link-freetext" href="http://www.sci.utah.edu/~cates">http://www.sci.utah.edu/~cates</a>


On Fri, 30 Apr 2004, Laurent Mundeleer wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi James,

I've tried to convert the WatershedSegmentation1.cxx to grayscale 
images, but I still have problems (abnormal termination).
Here's my code :
--------------------
tumorFilterITK.h
--------------------
#ifndef tumorFilterITK_H
#define tumorFilterITK_H


#include &lt;itkVTKImageExport.h&gt;
#include &lt;itkVTKImageImport.h&gt;
#include &lt;vtkImageImport.h&gt;
#include &lt;vtkImageExport.h&gt;

#include &lt;itkGradientAnisotropicDiffusionImageFilter.h&gt;
#include &lt;itkGradientMagnitudeImageFilter.h&gt;
#include &lt;itkWatershedImageFilter.h&gt;
#include &lt;itkCastImageFilter.h&gt;

class tumorFilterITK
{

public:

    typedef short pixelType;

    typedef itk::Image&lt;pixelType, 3&gt; ImageType;
    typedef itk::Image&lt;unsigned long, 3&gt; ImageTypeOut;

    typedef itk::VTKImageImport&lt;ImageType&gt; ImageImportType;
    typedef itk::VTKImageExport&lt;ImageType&gt; ImageExportType;
 
    typedef itk::CastImageFilter&lt;ImageTypeOut, ImageType&gt; CastFilterType;

    typedef itk::GradientAnisotropicDiffusionImageFilter&lt;ImageType,    
ImageType&gt;  DiffusionFilterType;
    typedef itk::GradientMagnitudeImageFilter&lt;ImageType, ImageType&gt; 
GradientMagnitudeFilterType;
    typedef itk::WatershedImageFilter&lt;ImageType&gt; WatershedFilterType;

    tumorFilterITK(vtkImageImport*, vtkImageExport*);
    void tumorFilterITKExec();

private:

    ImageImportType::Pointer itkImporter;
    ImageExportType::Pointer itkExporter;

    CastFilterType::Pointer caster;

    DiffusionFilterType::Pointer diffusion;
    GradientMagnitudeFilterType::Pointer gradient;
    WatershedFilterType::Pointer watershed;
};

#endif
--------------------------------------------
--------------------
tumorFilterITK.cpp
--------------------

#include "tumorFilterITK.h"

/// connexion de ITK a VTK
template &lt;typename ITK_Exporter, typename VTK_Importer&gt;
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
{
  
importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());
  
importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());
  importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());
  importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());
  importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());
  importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());
  
importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());
  
importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());
  importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());
  importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());
  importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());
  importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());
}

//-----------------------------------------------------------------

/// connexion de VTK a ITK
template &lt;typename VTK_Exporter, typename ITK_Importer&gt;
void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer importer)
{
  
importer-&gt;SetUpdateInformationCallback(exporter-&gt;GetUpdateInformationCallback());
  
importer-&gt;SetPipelineModifiedCallback(exporter-&gt;GetPipelineModifiedCallback());
  importer-&gt;SetWholeExtentCallback(exporter-&gt;GetWholeExtentCallback());
  importer-&gt;SetSpacingCallback(exporter-&gt;GetSpacingCallback());
  importer-&gt;SetOriginCallback(exporter-&gt;GetOriginCallback());
  importer-&gt;SetScalarTypeCallback(exporter-&gt;GetScalarTypeCallback());
  
importer-&gt;SetNumberOfComponentsCallback(exporter-&gt;GetNumberOfComponentsCallback());
  
importer-&gt;SetPropagateUpdateExtentCallback(exporter-&gt;GetPropagateUpdateExtentCallback());
  importer-&gt;SetUpdateDataCallback(exporter-&gt;GetUpdateDataCallback());
  importer-&gt;SetDataExtentCallback(exporter-&gt;GetDataExtentCallback());
  importer-&gt;SetBufferPointerCallback(exporter-&gt;GetBufferPointerCallback());
  importer-&gt;SetCallbackUserData(exporter-&gt;GetCallbackUserData());
}

//-----------------------------------------------------------------

///contructeur initialisant le pipeline ITK
tumorFilterITK::tumorFilterITK(vtkImageImport* vtkImporter, 
vtkImageExport *vtkExporter)
{       
    itkImporter = ImageImportType::New();
    itkExporter = ImageExportType::New();

//    itkExporter-&gt;SetInput(itkImporter-&gt;GetOutput());
    diffusion = DiffusionFilterType::New();
    gradient = GradientMagnitudeFilterType::New();
    caster = CastFilterType::New();

    watershed = WatershedFilterType::New();
   
    ConnectPipelines(vtkExporter, itkImporter);
    ConnectPipelines(itkExporter, vtkImporter);   

    tumorFilterITKExec();
}

//-----------------------------------------------------------------

/// execution du filtre de detection de tumeurs
void tumorFilterITK::tumorFilterITKExec()
{

     //inputImage outputImage conductanceTerm diffusionIterations 
lowerThreshold outputScaleLevel gradientMode " &lt;&lt; std::endl;

    diffusion-&gt;SetNumberOfIterations( 5 ); // 5 typically
    diffusion-&gt;SetConductanceParameter( 3.0 ); // 3.0 typically
    diffusion-&gt;SetTimeStep(0.125);

    watershed-&gt;SetLevel( 0.001 ); // 0-&gt;1 en %
    watershed-&gt;SetThreshold( 0.001 ); // 0-&gt;1 en %

    diffusion-&gt;SetInput(itkImporter-&gt;GetOutput());
    gradient-&gt;SetInput(diffusion-&gt;GetOutput());
    watershed-&gt;SetInput(gradient-&gt;GetOutput());

    try
    {
    watershed-&gt;Update();
    }
    catch (itk::ExceptionObject &amp;e)
    {
    std::cerr &lt;&lt; e &lt;&lt; std::endl;
    }
    caster-&gt;SetInput(watershed-&gt;GetOutput());
    itkExporter-&gt;SetInput(caster-&gt;GetOutput());
}

------------------------------------

Maybe can you help me?
Thanks again,

Regards,

Laurent



Miller, James V (Research) wrote:

    </pre>
    <blockquote type="cite">
      <pre wrap="">Watershed can be run on grayscale images.  The example
(WatershedSegmentation1.cxx) is set up to process RGB pixels. But you can
easily run watershed on a grayscale image.

You'll want to create a similar program to WatershedSegmentation1.cxx that
reads a scalar image, produces a gradient magnitude image
(GradientMagnitudeImageFilter or RecursiveGradientMagnitudeImageFilter), and
runs watershed on the gradient magnitude image.

So you just need to change the pixel type, delete the word "Vector" from any
class type in example, and change the CastType to a CastImageFilter that
converts a scalar image into an image of floating point pixels (alternative,
you can remove the cast filter altogether and have the reader return an
image of floating point pixels.  Here is a quick stab at it (haven't tried
to compile it....)

#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#endif

#include &lt;iostream&gt;

#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "itkGradientMagnitudeImageFilter.h"
#include "itkWatershedImageFilter.h"

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkScalarToRGBPixelFunctor.h"

int main( int argc, char *argv[] )
{
 if (argc &lt; 8 )
   {
   std::cerr &lt;&lt; "Missing Parameters " &lt;&lt; std::endl;
   std::cerr &lt;&lt; "Usage: " &lt;&lt; argv[0];
   std::cerr &lt;&lt; " inputImage outputImage conductanceTerm
diffusionIterations lowerThreshold outputScaleLevel gradientMode " &lt;&lt;
std::endl;
   return 1;
   }
 
 typedef itk::RGBPixel&lt;unsigned char&gt;   RGBPixelType;
 typedef itk::Image&lt;RGBPixelType, 2&gt;    RGBImageType;
 typedef itk::Image&lt;unsigned long, 2&gt;   LabeledImageType;
 typedef itk::Image&lt;float, 2&gt;           ScalarImageType;

 typedef itk::ImageFileReader&lt;ScalarImageType&gt; FileReaderType;
 typedef itk::GradientAnisotropicDiffusionImageFilter&lt;ScalarImageType,
   ScalarImageType&gt;  DiffusionFilterType;
 typedef itk::GradientMagnitudeImageFilter&lt;ScalarImageType&gt;
   ScalarMagnitudeFilterType; 
 typedef itk::WatershedImageFilter&lt;ScalarImageType&gt; WatershedFilterType;
 // Software Guide : EndCodeSnippet

 typedef itk::ImageFileWriter&lt;RGBImageType&gt; FileWriterType;

 FileReaderType::Pointer reader = FileReaderType::New();
 reader-&gt;SetFileName(argv[1]);
 
 DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
 diffusion-&gt;SetNumberOfIterations( atoi(argv[4]) );
 diffusion-&gt;SetConductanceParameter( atof(argv[3]) );
 diffusion-&gt;SetTimeStep(0.125);


 GradientMagnitudeFilterType::Pointer gradient =
GradientMagnitudeFilterType::New();
 gradient-&gt;SetUsePrincipleComponents(atoi(argv[7]));


 WatershedFilterType::Pointer watershed = WatershedFilterType::New();
 watershed-&gt;SetLevel( atof(argv[6]) );
 watershed-&gt;SetThreshold( atof(argv[5]) );


 typedef itk::Functor::ScalarToRGBPixelFunctor&lt;unsigned long&gt;
   ColorMapFunctorType;
 typedef itk::UnaryFunctorImageFilter&lt;LabeledImageType,
   RGBImageType, ColorMapFunctorType&gt; ColorMapFilterType;
 ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
 
 FileWriterType::Pointer writer = FileWriterType::New();
 writer-&gt;SetFileName(argv[2]);

 diffusion-&gt;SetInput(reader-&gt;GetOutput());
 gradient-&gt;SetInput(diffusion-&gt;GetOutput());
 watershed-&gt;SetInput(gradient-&gt;GetOutput());
 colormapper-&gt;SetInput(watershed-&gt;GetOutput());
 writer-&gt;SetInput(colormapper-&gt;GetOutput());

 try 
   {
   writer-&gt;Update();
   }
 catch (itk::ExceptionObject &amp;e)
   {
   std::cerr &lt;&lt; e &lt;&lt; std::endl;
   }
   
 return 0;
}





-----Original Message-----
From: Laurent Mundeleer [<a class="moz-txt-link-freetext" href="mailto:lmundele at ulb.ac.be">mailto:lmundele at ulb.ac.be</a>]
Sent: Thursday, April 29, 2004 6:10 AM
To: <a class="moz-txt-link-abbreviated" href="mailto:insight-users at itk.org">insight-users at itk.org</a>
Subject: [Insight-users] watershed segmentation without RGB?


Hi all,

I'd like to apply the watershed filter to CT images, is it possible? In 
the documentation, it 's specified that RGB values are required...
How can I do?

Thanks in advance

Regards,

Laurent

 

      </pre>
    </blockquote>
    <pre wrap="">-- 
********************************************
Laurent Mundeleer
Universit&eacute; Libre de Bruxelles (ULB)
Service des Syst&egrave;mes Logiques et Num&eacute;riques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : <a class="moz-txt-link-abbreviated" href="mailto:lmundele at ulb.ac.be">lmundele at ulb.ac.be</a>
********************************************

_______________________________________________
Insight-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Insight-users at itk.org">Insight-users at itk.org</a>
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
********************************************
Laurent Mundeleer
Universit&eacute; Libre de Bruxelles (ULB)
Service des Syst&egrave;mes Logiques et Num&eacute;riques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : <a class="moz-txt-link-abbreviated" href="mailto:lmundele at ulb.ac.be">lmundele at ulb.ac.be</a>
********************************************</pre>
</body>
</html>

--------------020709020908070409070801--