[Insight-users] Problem with watershed filter

Luis Ibanez luis.ibanez at kitware.com
Fri Nov 9 18:23:16 EST 2007


Hi Orientation f,

Most likely you are dealing with a pixel type issue,
not a segmentation problem.

Note that the pixel type of the image produced by the
watershed filter is unsigned long, and that the values
of the watershed are labels of regions, so their values
are arbitrary.

Using a rescale image filter on the output of a watershed
filter doesn't makes much sense. What you probably need
is to use the color encoding illustrated in the ITK
Software Guide


    http://www.itk.org/ItkSoftwareGuide.pdf

In section 9.2.2, "Using the ITK Watershed Filter", in
particular, look at pdf-pages 560-561 and to figure 9.12.



If you also want help with the error produced by the
writer when saving the .dcm image, then please please
please please, post to the list the *exact* error message
that you get.



    Thanks



        Luis



--------------------
orientation f wrote:
> 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
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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