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

Richard Beare richard.beare at gmail.com
Fri Feb 19 04:58:25 EST 2010


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.

1) Simple thresholding followed by connected component labelling. If
your background is smooth and your blobs are separated then this will
work.

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.

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.

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.

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.

The watershed can have an advantage in allowing a bit more flexibility
in dealing with touching blobs and the way you start the process with
markers.



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.

On Fri, Feb 19, 2010 at 7:19 PM,  <lynx.abraxas at freenet.de> wrote:
> On 19/02/10 08:50:47, Richard Beare wrote:
>> Hi,
>> I think I understand what you're getting at. I think that what you
>> want to do is find the first grey level at which a basin meets a
>> neighbour and designate members of the basin that are less than that
>> as members of your ourput label. It has to be strictly less than,
>> otherwise plateaus between basins will be included. I don't recognise
>> this offhand as a standard operation or as equivalent to any standard
>> combination. I'll have to think about that further. Note that while it
>> looks like a useful thing in 1D there is a fair chance that it will
>> prove a lot less useful in 2Dor 3D, but it is worth checking out.
>
> Yes,  that's  what  I want. Couldn't have explained it better. I made a few 2D
> pic showing the process I'm thinking of. They are attached.
>
> I started with  some  thing  like   gauss-spalts   (gaus-spalt_02-70.png,  the
> magenta splat is missing here).  I  used
> gimp  to  do this and then used the region growing "magic wand" tool to select
> the areas starting from each minimum until the region flooded  another  basin.
> The  result gaus-spalt_02-70_loc-min_02.png is what I'm looking for but in 3D.
> Pic gaus-spalt_02-70_loc-min_04.png shows the evolution of the filter:
> - If my understanding is correct the  watershed  filter  starts  flooding  the
> magenta area first.
> -  At some time it reaches the level at which the red area starts to be filled
> as well and then green
> - Just when green and red meet and a watershed would be introduced the  labels
> red and green should go in the output.
> -  The  flooding goes on an when the red-green pool is just before hitting the
> blue one the bleu goes in the output as well.
> - Then finally the yellow pool hits the magenta one and then magenta  goes  in
> the output.
> -  No  further watersheds will be needed so the filter output would not change
> further.
>
> In the resulting output each label marks the area in which  every  grey  value
> has  a destinct minimum, the local minimum within the area of the label. So as
> soon a grey level is reached where  other  extreme  points  are  found  (local
> maxima  in 1D, saddel points in 2D and ... points (I don't know their name) in
> 3D) the growing of the label ends.
>
> I'll ask some mathematician about this. So what would be the  easiest  of  the
> three suggestions from You and Gaėtan to get this result?
> Why  is  the  fill  holes filter not suitabel for this? In the API doc of fill
> holes it says by substraction and thresholding the result one  would  get  the
> regions of the local minima. In what way do those regions differ to the ones I
> want?
>
>
> Thanks a lot for looking into this.
> Lynx
>


More information about the Insight-users mailing list