[Insight-users] Bug in watershed filter

Dženan Zukić dzenanz at gmail.com
Wed Feb 13 19:19:09 EST 2013


I also suspected that at first, but the deviations are a lot bigger than
what can be explained by discretization. Also, this should not be that much
a problem for float images, but problem appears there as well. Most
importantly of all, detected watershed lines do not lie where visual
inspection expects them to be. One one slice I examined, the watershed line
was shifted about 10 voxels!


On Wed, Feb 13, 2013 at 6:35 PM, Richard Beare <richard.beare at gmail.com>wrote:

> I'll attempt to check this out over the next couple of days.
>
> I suspect that you have run into issues with discrete nature of
> images, rather than a bug as such. Suppose that you are applying a
> watershed to a flat control surface. If the seed points are an odd
> number of voxels apart, and you chose the algorithm marking the
> watershed line, then the split will appear nicely down the middle. If
> you don't chose to mark the line then there will be a probably random
> choice of which voxels along the midpoint get assigned to which
> region. Conversely, if the seeds are an even number of voxels apart
> and you chose to mark the watershed line, then the line should lie
> between the pixels, but it can't. Hence it is likely to be jaggedly
> jumping between the two sides of the plateau. Similar things can
> happen with distance map control functions, as adjacent voxels can be
> equidistant from seeds, producing a plateau.
>
>
> On Thu, Feb 14, 2013 at 9:13 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
> > I think I have discovered a bug in WatershedImageFilter. Below is MWE
> which
> > reproduces the problem. Input, output and expected image attached.
> >
> > The problem is that watershed lines are wrongly placed and rough (see
> > attached error highlights). I first discovered it while working with 3D
> > images, where the problem is more pronounced. I can also supply 3D float
> > images (1.3MB). MorphologicalWatershedFromMarkersImageFilter suffers from
> > the same problem.
> >
> > #include <itkImageFileReader.h>
> > #include <itkImageFileWriter.h>
> > #include <itkWatershedImageFilter.h>
> > #include <itkCastImageFilter.h>
> >
> > typedef itk::Image<unsigned char, 2> VisualizingImageType;
> >
> > void main()
> > {
> >     typedef itk::ImageFileReader<VisualizingImageType> rType;
> >     rType::Pointer reader=rType::New();
> >     reader->SetFileName("image2D.png");
> >     reader->Update();
> >     VisualizingImageType::Pointer dm=reader->GetOutput();
> >     typedef itk::WatershedImageFilter<VisualizingImageType> wsType;
> >     wsType::Pointer ws2=wsType::New();
> >     ws2->SetThreshold(0);
> >     ws2->SetLevel(0);
> >     ws2->SetInput(dm);
> >     ws2->Update();
> >     typedef itk::CastImageFilter<wsType::OutputImageType,
> > VisualizingImageType> castType;
> >     castType::Pointer caster=castType::New();
> >     caster->SetInput(ws2->GetOutput());
> >     caster->Update();
> >     typedef itk::ImageFileWriter<VisualizingImageType> wType;
> >     wType::Pointer writer=wType::New();
> >     writer->SetFileName("imageWSint.png");
> >     writer->SetInput(caster->GetOutput());
> >     writer->Update();
> > }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/846eabe3/attachment.htm>


More information about the Insight-users mailing list