<div dir="ltr"><font><div><span style="font-family:verdana,sans-serif">I think I have discovered a bug in </span><font face="courier new, monospace">WatershedImageFilter</font><font face="verdana, sans-serif">. Below is MWE which reproduces the problem. Input, output and expected image attached.</font></div>
<div style="font-family:verdana,sans-serif"><br></div><div><font face="verdana, sans-serif">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). </font><font face="courier new, monospace">MorphologicalWatershedFromMarkersImageFilter </font><font face="verdana, sans-serif">suffers from the same problem.</font></div>
</font><font><div style="font-family:verdana,sans-serif"><br></div><div><font face="courier new, monospace">#include <itkImageFileReader.h></font></div><div><font face="courier new, monospace">#include <itkImageFileWriter.h></font></div>
<div><font face="courier new, monospace">#include <itkWatershedImageFilter.h></font></div><div><font face="courier new, monospace">#include <itkCastImageFilter.h></font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">typedef itk::Image<unsigned char, 2> VisualizingImageType;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">void main()</font></div>
<div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace"> typedef itk::ImageFileReader<VisualizingImageType> rType;</font></div><div><font face="courier new, monospace"> rType::Pointer reader=rType::New();</font></div>
<div><font face="courier new, monospace"> reader->SetFileName("image2D.png");</font></div><div><font face="courier new, monospace"> reader->Update();</font></div><div><font face="courier new, monospace"> VisualizingImageType::Pointer dm=reader->GetOutput();</font></div>
<div><font face="courier new, monospace"> typedef itk::WatershedImageFilter<VisualizingImageType> wsType;</font></div><div><font face="courier new, monospace"> wsType::Pointer ws2=wsType::New();</font></div><div>
<font face="courier new, monospace"> ws2->SetThreshold(0);</font></div><div><font face="courier new, monospace"> ws2->SetLevel(0);</font></div><div><font face="courier new, monospace"> ws2->SetInput(dm);</font></div>
<div><font face="courier new, monospace"> ws2->Update();</font></div><div><font face="courier new, monospace"> typedef itk::CastImageFilter<wsType::OutputImageType, VisualizingImageType> castType;</font></div>
<div><font face="courier new, monospace"> castType::Pointer caster=castType::New();</font></div><div><font face="courier new, monospace"> caster->SetInput(ws2->GetOutput());</font></div><div><font face="courier new, monospace"> caster->Update();</font></div>
<div><font face="courier new, monospace"> typedef itk::ImageFileWriter<VisualizingImageType> wType;</font></div><div><font face="courier new, monospace"> wType::Pointer writer=wType::New();</font></div><div><font face="courier new, monospace"> writer->SetFileName("imageWSint.png");</font></div>
<div><font face="courier new, monospace"> writer->SetInput(caster->GetOutput());</font></div><div><font face="courier new, monospace"> writer->Update();</font></div><div><font face="courier new, monospace">}</font></div>
</font></div>