[Insight-users] Stop flooding pools when "water sheds" would be introduced or use "fill holes" for that

Richard Beare richard.beare at gmail.com
Sun Feb 21 06:45:09 EST 2010


The problem of segmentations being too small when using watershed can
often occur when the blob is small - i.e. say 5 pixels across. In such
cases the gradient is high everywhere in the blob due to the size of
the smoothing kernel you use with the gradient. Hence, when you put a
marker in at the minimum it is already on a zone of high gradient and
doesn't grow much. Naturally the second derivative won't help much
there either - you're basically getting stuck at the resolution limits
of the data. My hack in these situations is to find the markers using
a top hat filter based on area attributes. This typically gives a good
segmentation for small blobs and a decent marker for bigger ones (you
can superimpose the regional minima to be sure). Then if you apply the
watershed transforms the markers for the small blobs won't change much
while the markers for the bigger ones grow nicely.

We were probably being lazy using the gradientmagnitude filter twice.
I don't think there is any easy to use 2nd derivative filter.

I don't understand what might be going wrong with the hole filling
approach - I don't think it should be a rounding problem.

On Sun, Feb 21, 2010 at 8:42 PM,  <lynx.abraxas at freenet.de> wrote:
> On 19/02/10 20:58:25, Richard Beare wrote:
>> I think there are a couple of things to check out. First, presuming
>> this is really an applied problem, then you'll need to be prepared for
>> the reality that holes that look like a single regional minima are
>> actually multiple minima, but you probably want to segment them as one
>> blob. Also, blobs will touch and you really want multiple labels. The
>> pictures look like a standard blob finding problem which can be
>> tackled in a number of ways depending on the exact nature of blobs.
>> If, of course, you have a theoretical interest in the approach we've
>> already discussed then ignore these suggestions and skip to the end of
>> the email.
>
> Thanks a lot Richard for Your answers. They helped me a lot.
>
>> 1) Simple thresholding followed by connected component labelling. If
>> your background is smooth and your blobs are separated then this will
>> work.
>
> I tried this, but since my image is a purly cumputed one I have no nois but it
> can happen that I have two blobs (gauss splats) of different  depth  close  to
> each other and then this is not a good solution.
>
>> 2) Watershed type approach - use regional minima as markers. Carry out
>> a watershed that produces a watershed line (the MarkWatershedLine
>> option). Use the watershed line as a background marker - i.e. create a
>> marker image with the regional minima and the background marker and
>> repeat the watershed, but use the gradient magnitude of the input as
>> your control image. This will give you a result that is restricted to
>> the basin. However you might find that the regions are smaller than
>> you like - they have borders at the zone of maximum gradient. You can
>> repeat the process by using the basin result as one marker set and
>> combine with the original background image and use the second
>> derivative as the control image.
>
> This  one I like very much and when I implemented it I saw that I'd read about
> this before in the contribution of the morphological watershed  but  I  didn't
> fully understand it then.
> I've  now  implemented  this in my program but it turns out that in most cases
> the labels are still to small even when I use the second derivative.
>
> I just noticed that I used itkGradientMagnitudeImageFilter twice for  the  2nd
> derivative but that's wrong isn't it?
> So  what  filter  should  I  use?  In  the  contribution  of Yours and Gaëtans
> itkGradientRecursiveGaussianImageFilter is used twice but the second time also
> on  the  magnitude of the first. Shouldn't the second derivative be taken from
> the vector image?
> Also I think for my problem an additional smoothing is not apropriate.
>
>
>> There are a couple of other tricks you might want to consider if this
>> approach sounds interesting. Regional minima are sensitive to noise,
>> so a tophat filter involving are attributes, or a reconstruction
>> operation can be useful in finding more stable markers. Also, you may
>> be able to use a conservative threshold to find a background marker
>> instead of messing around with the watershed line.
>
> I just use hminima to disregard blobs of low depth, since this I can relate to
> a physical meaning in my problem and I know there is no noise.
>
>> The basic difference between this approach and what you've been doing
>> so far is the use of the background marker that stabilises the entire
>> process.
>
> Yes this idea is really cool.
>
>> 3) Depending on the size and brightness of the blobs, you may be happy
>> with one of the marker finding steps, such as the tophat filter by
>> area attributes. The hole filling filter you mention is basically a
>> reconstruction operation, so the difference between the filled and
>> original will give you blobs. If you threshold and label it you might
>> end up with a satisfactory result. The problem that you are having may
>> simply be that hole filling returns a standard image, whereas you are
>> apparently after a label image.
>
> Well  this  is  basicly  what  I  tried  before  with  an additional connected
> component lableing but the thresholded result of the difference is either  all
> white  (thresholding everything != 0) or the labels are far too small if I use
> the same threshold as I use for the hminima in the ws version.
> Up to the thresholding all my images are  of  type  float.  Could  this  be  a
> rounding problem?
>
>> Finally, if you are pursuing this out of theoretical interest, then
>> neither of the options are particularly difficult to implement, but
>> you'll have to write or adapt a filter or two. The component tree is a
>> much nicer and more flexible option, but I don't know the state of the
>> code or whether it includes information about how regions touch one
>> another. I'd recommend checking out Gaetan's implementation  and only
>> pursue my suggestions as a last resort.
>
> Well  I'm just after a result but since so far the labels are too small I fear
> I've to start modifing some code but I've no real clue where to start and what
> to do. I'll come back to this when I've more precise questions.
>
>
> Thanks very much for all Your help, suggestions and advice.
> Lynx
>
>


More information about the Insight-users mailing list