[Insight-users] Bug in watershed filter

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


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/cbad59cd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image2D.png
Type: image/png
Size: 20656 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/cbad59cd/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imageWS.png
Type: image/png
Size: 3686 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/cbad59cd/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imageWScorrect.png
Type: image/png
Size: 3407 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/cbad59cd/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imageWSerrors.png
Type: image/png
Size: 5238 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/cbad59cd/attachment-0003.png>


More information about the Insight-users mailing list