Blob color detection

dca's icon

Hi!
Can anyone help me to detect blobs by color?
I need to count the number of blobs of one color in a video (or picture).
I can track a color, but what I need to know is how many spots of the same color exist.
Thanks if you can help. :)

laserpilot's icon

Probably plenty of other information out here on the forum.

One thing I would try is something like jit.chromakey to isolate the color you want, then feed that output into a jit.rgb2luma into something like cv.jit.blobs so that you're only doing computer vision on that one color.

You could also do it with a jit.expr or getting fancy with jit.op depending on the color, but you would be best to isolate the color first, and then do blob counting and depending on your skillset, jit.chromakey is probably easiest

dca's icon

Thanks for your help laserpilot!

I'm not a big expert with max, but with what you told me and some search, i could copy some parts of other patches and build mine. Now i can detect blobs of a determined color and know how many they are.

Max Patch
Copy patch and select New From Clipboard in Max.

This is what i have:

But i'm having a problem. If I have different size blobs, the counting could be wrong, 'cause the radius that is ok for signing a small blob will fill a bigger blob full of blob signs.

The cv.jit.thouches, gives me the blobs and the number of blobs, that's nice.

The cv.jit.blobs.bounds, gives me the exact form of the blob. But i can't count the number of blobs.

Can i have both? Or something to solve this problem?

Thanks again!

dca's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Well.. I solved my problem.
I don't know if it's the best way, but it's ok for me.
If someone need the same, here it goes:

I solved with cv.jit.blobs.bounds. I can have the right shape of the blob and the number of blobs.