<div dir="ltr"><font><font face="verdana,sans-serif">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!</font></font></div>

<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 13, 2013 at 6:35 PM, Richard Beare <span dir="ltr">&lt;<a href="mailto:richard.beare@gmail.com" target="_blank">richard.beare@gmail.com</a>&gt;</span> wrote:<br>

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