[Insight-users] Bug in watershed filter

Richard Beare richard.beare at gmail.com
Wed Feb 13 22:58:02 EST 2013


The distance field is the right thing to use in this case. I think the
cause of jaggedness with watershed outputs is likely to be casting that
produces ties in the control function.

The jaggedness in my new method is a bug though. It definitely shouldn't be
there as there aren't large plateau areas in the underlying distance
function

On Thu, Feb 14, 2013 at 2:54 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>wrote:

> Hello I ran the following commands in SimpleITK with the attached output:
>
> img = sitk.ReadImage( "/Users/blowekamp/Downloads/image2D.png" )
> img = sitk.VectorIndexSelectionCast( img , 0 )
> ws = sitk.MorphologicalWatershed( img )
>
> [image: unknown.png]
>
>
> These are the default arguments for the morphological watershed function:
>
> Image itk::simple::MorphologicalWatershed(const Image &image1, double level=0.0, bool markWatershedLine=true,
> bool fullyConnected=false)
>
>
> I am suspicious there there is some integer type used for a distance filed
> someplace in your code or other subtle misuse. Also I have generally plug a
> gradient image into the classic itk::WatershedImagefilter and not a
> distance filed.
>
> Brad
>
> On Feb 13, 2013, at 7:19 PM, Dženan Zukić <dzenanz at gmail.com> wrote:
>
> 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();
>> > }
>>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130214/634244f2/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 13693 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130214/634244f2/attachment-0001.png>


More information about the Insight-users mailing list