pixels[] Question
in
Programming Questions
•
1 year ago
Howdy All,
At the end is the code snippet from the reference manual for pixels[].
So, you can set the color using an english word describing the color (in the case below, "pink"). My question is can you feed it a set of RGB values and get the english equivalent word back? So, (255, 255, 0) would return "yellow." Essentially, query pixels[] and instead of the RGB values, it returns the english equivalent word.
Is this possible? I am working on some code (will have other questions about it soon!) that goes through a series of images and counts the number of pixels in each that are red, yellow, and green. For example, to classify a pixel as red the R value has to be above 200 and the other two values have to be below 50. But I am testing this on "perfect" test images and the actual working images will have varying shades of each color and I will need to account for that. I'm playing around with ways to compare each of the values to each other, but that can get rather tedious...
If one cannot get the english color name back, are there any functions that can classify various shades of a given color as the color? Or will I have to "brute force" it?
Thanks!
james
color pink = color(255, 102, 204); loadPixels(); for (int i = 0; i < (width*height/2)-width/2; i++) { pixels[i] = pink; } updatePixels();
1