Try this patch. It’s just a color-tracking , but you can simple integrate it with you own portion of objects (just insert [r colorBounds1], [r colorBounds2] and [r colorBounds3] to the patch to receive data from color-trackers).
This patch can track 3 colors (red, green, blue on beginning – but you can change it, if you want) in the same time. Play a bit with tolerance parameter for every tracker and with brcosa (especially saturation).
If you want to change one of the colors to track choose tracker from menu in "displays and color selector" area, and click on pwindow (color of the pixel will be sent to the tracker).
This should be a bit more flexible solution, compared to the previous one, even if is a bit more complex (btw: I’m sure this is something that can be simplified).
Have fun with the patch and tell mi, if something is wrong or unclear.