Merge / combine blobs

In nearly all vision projects I get a blob that is broken into smaller parts. I’ve read in some research papers about merging blobs, based on their distance, or overlaps etc, so have decided to give it a go.

Here is the normal video, see how there are many blobs
http://www.chrisoshea.org/storage/vid/p-…-=320&h=240

Here is the same binary image with dilate 3x3 applied which solves some of the problems
http://www.chrisoshea.org/storage/vid/p-…-=320&h=240

Here is an undilated video. I merge all of the blobs into one cvSeq, creating one blob.
http://www.chrisoshea.org/storage/vid/p-…-=320&h=240

However of course drawing from point to point creates end/start crossover lines. But more importantly for me, the shape of the person isn’t as good as it could be. Those gaps in between each blob are unconnected pixels.

I’m trying to work out approaches possibly using a growing algorithm to fill in those spaces, or possibly compare each point of the contour on each blob to maybe make new points or remove points.

I was wondering if anyone had any thoughts on this?

yeah, this can be a tricky one.

in my experience, trying to do anything ‘clever’ involving logical extensions of things, is nigh-on impossible.

there are a couple of things to think about though:

* often computer vision problems can get much better results if you use two completely different algorithms at the same time and merge their result sets.

* you could try tracking at a low resolution to get a rough idea of what’s going on, then build up a hierarchical tree of results. for example, shrink the input image down to 16 pixels wide by 12 pixels high, and find ‘blobs’ of size 1 pixel. do that again with a 32x24 or 64x48 pixel image, using your lower-res image as a mask. and repeat. and repeat. if you get a single blob at a low level that becomes two or three at a higher level, use the lower level data to ‘fill in the blanks’. i haven’t tried this, so it may or may not work, but it sounds pretty clever, eh? :wink: Google ‘quadtree’.

[quote author=“chrisoshea”]
I’m trying to work out approaches possibly using a growing algorithm to fill in those spaces, or possibly compare each point of the contour on each blob to maybe make new points or remove points.

I was wondering if anyone had any thoughts on this?[/quote]
Based in your videos, i see the easiest way is to find the minimum enclosing polygon of the contour points.

Another way to go is to join the all the contour points in some order, then apply a lowpass filter based on angles (ie. ignore, delete or “soften” very sharp angles). This should be easy to implement and will run fast.

Hi chris, this is quite a simple suggestion, and might be a bit stupid… but would it work for you if you did a blur + threshold? I usually do that to smooth things out and get rid of little holes. depeding on where you apply the threshold, your overall contours might expand or shrink, but by balancing the blur amount vs threshold, you can keep the overall outline roughly the same size while connecting close areas.