[Insight-users] difficulties on watershed for gray Images

Luis Ibanez luis.ibanez at kitware.com
Fri Jul 16 10:34:45 EDT 2004


Hi Anis,

Please post the warning messages that you get.


Thanks


   Luis


---------------------------------------
sd d wrote:

> I tried to modify the code of watershed segmentation given in the 
> examples,but i have 19 warnings then an abnormal termination when 
> running: WatershedSegmentation Image.png Resultat.png
> Someone can help me, please?
> here is the code.
> 
> ------------------------------------------------------------------------
> 
> 
> #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 < 3 )
>     {
>     std::cerr << "Missing Parameters " << std::endl;
>     std::cerr << "Usage: " << argv[0];
>     std::cerr << " inputImage outputImage " << std::endl;
>     return 1;
>     }
> //import sys;
> 
> 
> 	typedef unsigned char   PixelType;
>   typedef itk::Image<PixelType, 2>    ImageType;
>   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::GradientMagnitudeImageFilter<ScalarImageType,ScalarImageType> GradientMagnitudeFilterType; 
>   typedef itk::WatershedImageFilter<ScalarImageType> WatershedFilterType;
>   // Software Guide : EndCodeSnippet
> 
>   //  typedef itk::ImageFileWriter<ImageType> FileWriterType;
>   typedef itk::Image< unsigned long, 2> OutputImageType;
> 	typedef itk::ImageFileWriter< OutputImageType > FileWriterType;
> 
> 
> 
>   FileReaderType::Pointer reader = FileReaderType::New();
> 	reader->SetFileName( argv[1] );
> 	DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
> //diffusion = itk.itkGradientAnisotropicDiffusionImageFilterF2F2_New();
> diffusion->SetInput(reader->GetOutput());
> diffusion->SetTimeStep(0.0625);
> diffusion->SetConductanceParameter(9.0);
> diffusion->SetNumberOfIterations(  5 );
> GradientMagnitudeFilterType:: Pointer gradient =GradientMagnitudeFilterType::New();
> //gradient = itk->itkGradientMagnitudeImageFilterF2F2_New();
> gradient->SetInput(diffusion->GetOutput());
> WatershedFilterType::Pointer watershed = WatershedFilterType::New();
> //watershed = itk->itkWatershedImageFilterF2_New();
> watershed->SetInput(gradient->GetOutput());
> watershed->SetThreshold(0.1);
> watershed->SetLevel(0.6);
> 
> //writer = itk->itkImageFileWriterUL2_New();
> FileWriterType::Pointer writer = FileWriterType::New();
> writer->SetFileName( argv[2] );
> writer->SetInput( watershed->GetOutput()  );
> writer->Update();}
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list