[Insight-users] Problem with watershed filter

orientation f fuzengliang435 at gmail.com
Wed Oct 17 08:01:23 EDT 2007


Hi,
I segment the image with watershedImageFilter. But only the top-half of
the image has result after watershed segmentation, the bottom-half of the
image is blank.
There are two parameters in watershedImageFilter, is there any rough rule to
set the level and theshold for a given image?
My code is as follows:
//******code

typedef float InternalPixelType;
 const unsigned int Dimension = 2;
 typedef itk::Image< InternalPixelType, Dimension > InternalImageType;

 typedef unsigned char OutputPixelType;
 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;

 typedef unsigned long  tempPixelType;
 typedef itk::Image<tempPixelType,Dimension> tempImageType;

 typedef itk::ImageFileReader< InternalImageType > ReaderType;
 typedef itk::ImageFileWriter< InternalImageType> WriterType;


 ReaderType::Pointer reader=ReaderType::New();
 typedef itk::GDCMImageIO DCMIamgeIo;
    DCMIamgeIo::Pointer gdcmImageIO=DCMIamgeIo::New();
    reader->SetFileName("BrainProtonDensitySlice.png");
   // reader->SetImageIO(gdcmImageIO);

 /*
 WriterType::Pointer writer1=WriterType::New();
  writer1->SetInput(reader->GetOutput());
  writer1->SetFileName("shuchu.dcm");
  writer1->SetImageIO(gdcmImageIO);
  writer1->Update();*/

//*****above writer setences also have error when execute the pragram???

 typedef
itk::GradientAnisotropicDiffusionImageFilter<InternalImageType,InternalImageType>
  diffusionFilterType;
 diffusionFilterType::Pointer diffusion=diffusionFilterType::New();

 typedef
itk::GradientMagnitudeImageFilter<InternalImageType,InternalImageType>
gradientMagnitudeFilterType;
 gradientMagnitudeFilterType::Pointer
gradientMagnitude=gradientMagnitudeFilterType::New();
 typedef itk::WatershedImageFilter<InternalImageType> watershedFilterType;
 watershedFilterType::Pointer watershed=watershedFilterType::New();

 diffusion->SetNumberOfIterations(5);
 diffusion->SetConductanceParameter(9);
 diffusion->SetTimeStep(0.125);

 watershed->SetLevel(0.15);//control the lower thresholding of the input
 watershed->SetThreshold(0.06);//control watershed depth

 typedef itk::RescaleIntensityImageFilter<tempImageType,InternalImageType>
RescaleFilterType;
 RescaleFilterType::Pointer rescaler = RescaleFilterType::New();


 //Pipeline
 diffusion->SetInput(reader->GetOutput());
 gradientMagnitude->SetInput(diffusion->GetOutput());
 watershed->SetInput(gradientMagnitude->GetOutput());
 rescaler->SetInput(watershed->GetOutput());
 rescaler->Update();

//*******end

thanks a lot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071017/faf76057/attachment.html


More information about the Insight-users mailing list