MAX MSP COLOUR DETECTION - Help needed
Hi guys - I'm pretty new to Max so this may be quite a simple idea.
I''ve bult an additive synthesizer and I'm looking to use the jit.object(s) (for video-based colour detection) as a means of triggering user specificied notes on a kslider. I found a thread on here from a while back where someone managed to implement red, green and blue colour detection, my problem however is I'm not sure how to build colour detection for other colours such as yellow / purple / orange etc. I have tried numerous different ideas like obtaining the RGBA values from an exact colour - however when I implement these into my patch it doesn't work. I have also tried switching from RGBA to ARGB (for the jit.findbounds object), but his also had no effect.
Are there set values for particular colours that can be implemented, or is there a more complex issue concerning how the colour values need to be translated for the jit.findbounds object?
Any help on this would be really appreciated - I'm all out of ideas at the moment, and so were my tutors!
Thanks
Detect the color of what exactly? A single pixel? A shape? A blob? The average of a given region? This can be trivial to.. not-so-trivial - depending on what you are doing. For reference, RGBW and CMYK correspond to the eight possible 3-bit binary numbers: 111 to 000 (ex. yellow = 110) For specific color names and values, check out: https://en.wikipedia.org/wiki/List_of_colors:_A–F
In this instance a colour card (approx. 10cm height, 5cm width). I'm basically trying to build a patcher that plays a note/notes upon detecting a particular colour, then ceases to play when the colour is no longer present.
(Also thanks for getting back to me so quick!)
Okay, to clarify... it's a physical card and you want to read the color in Max using a camera... and then compare the value to a specific set of colors for the closest match.
The first thing that comes to mind is lighting. You can get VERY different values depending on your light source, whether the card is tilted, there is glare, etc etc. For best results, the cards should be read at a fixed distance with identical lighting. The more control you have, the more accurate your results. A simple card holder for fixed distance and lighting that is near the card should work fine. Beware of background lights, spots, etc. hitting the card when it's being read.
In terms of Max.. you can use a simple color difference calculation (CIE delta E 1976) to calculate the perceptual "distance" between two colors. Sounds fancy but it's easy. In this case, you might have a [coll] object with a list of reference colors and use the camera input as your sample. Dump the coll values, comparing each one with your sample. Grab the color with the lowest delta E value. There are a few more details I left out, but that's the basic idea. I can post some tools to make it easier if this jibes with your overall plan.
Yeah it's a physical card.
If you wouldn't mind that would be really helpful. Thanks!
You still have a lot to work out in terms of implementation but here's a start...
1. [coll] to store reference colors.
2. [jit.grab] for video image and [jit.3m] to get the average RGB value
3. Dump the [coll] to compare each value with the video sample.
4. Convert all colors to L*ab
5. Calculate the color difference between the references and the sample.
6. The lowest delta E value is the closest reference match to the sample
Be sure to position the camera and/or crop the image so the card color fills the entire frame - otherwise you will be averaging background colors. You can use [jit.submatrix] to do that.
I know this was ages ago that you posted this but I think you can help Metamax!! I am working on a project that I think your example above could help with some tweeking... Would you know how to miss-match that patch to actually show the color that is the closest to the video sample? So instead of picking a color, the info from the video sample would pick the closest from the coll colorlist for you?
The zl.sub object does the heavy lifting for you.
I am another person this has helped in 2020, thanks Metamax! I used this as a base for identifying colour from a TCS34725 RGB colour sensor. I added a bunch of other features to adjust for sensitivity, specific to this sensor. I think when I have time I'll post it either on my website, or on github. And I'll definitely included a link to this thread to reference where the initial idea came from.
I am trying to get Max to receive information from a colour sensor (input), and link this to the colours of an LED strip. I already have the LED strip working, but not sure how to connect the colour sensor and translate this information. The colour sensor will be reading a continuous colour-range (red to white) and translating it to another colour scale in MAX. Does anyone know how I would do this?
which color sensor ?
if you have trouble to connect sensor, one could understand
that you don't know how to wire it.
or do you need help with sending or receiving RGB data between
your microprocessor and max ?
to get help, post infos, starting with sensor type,
what board you use to capture color sensor and control LEDS.
and any code you have so far, max and code for the board.