Color Tracking by setting a threshold for each color channel (jit.op problem)

Elokuu's icon

Hi everybody,

I'm totally new to this community and also pretty new to max/msp/jitter. I have done some computer vision, but in OpenCV.

However, my plan is to implement a patch who track three juggle balls (they have different colors) and depending on their height and horizontal position, they should effect some sound parameters (not sure which one yet).

As I'm said I'm new to max/msp so i tried to implement the color tracker how i did it in OpenCV: seperating each color channel and set a "threshold range" for each color channel. If the pixelvalue is in this range it becomes 1, otherwise 0.

My problem is now that I can't figure out how to write the expression. In c++ it would be something like:

if(pixelvalue > min && pixelvalue < max) pixelvalue=1;
else pixelvalue=0;

where min and max define the threshold range.

at the moment it is implemented that i can set a threshold and everything with a higher value then the threshold becomes 1, everything lower becomes 0.

It would be nice if somebody could give me some advise how todo it. Or maybe there is a much easier way to track colors!?

Thanks a lot and every advice is appreciated...

Have a nice evening :)

Here is my patch:

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

3399.maxmsppatch.jpg
jpg
Elokuu's icon

It wasn't that hard, after all:

And it works pretty nice already, even without filtering any noise.

3415.maxmsppatch2.jpg
jpg