Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What's the best way to segment different coloured blobs?

I have a requirement to segment an image like this into blobs of each colour. The goal is to find out how many blobs of each colour are present. That can be handled using findContours if I can create a binary image each for each coloured blobs. In the image below it would be - 3 blobs for red image, 1 green, 1 blue, 2 white/grey.

I've tried converting to the HSV color space and I can use the Hue channel to threshold whatever colour I want using cvInRange. But the problem is since the black background and white blobs also have an Hue value, I keep getting them in the results for other colours. Ideally, I need to eliminate the whites first and ignore the black background. Then get each of the other colours.

I tried splitting channels to extract specific channels too, before using cvInRange on it. - Core.extractChannel(mIn, v, 2);

Is there a better approach?

Image