We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › How to define a color range
Page Index Toggle Pages: 1
How to define a color range? (Read 457 times)
How to define a color range?
Nov 9th, 2007, 2:44am
 
I'm "scanning" an image (JPG) and extract color values in order to get a nice color palette for some experiments.

That all works like a charm, the values are stored in an array - but I'm wondering if there's a way to exclude a certain color range.

e.g. an image has nice shades of blue, but also a lot of white areas. How would I exclude the white hex colors from the array, so that I'm only left with the blue colors?
Re: How to define a color range?
Reply #1 - Nov 9th, 2007, 5:39am
 
negative of the image is black and yellow, does it help?
Re: How to define a color range?
Reply #2 - Nov 9th, 2007, 7:17am
 
Hi. Each color has red, green and blue components, varying from 0 to 255 (or 0.0 to 1.0). You can retrieve them using red(), green() and blue() methods.

Assuming that blue shades are around rgb(0, 0, 255), you could 'test' every color of your array to see if the amount of red, green and blue for this specified color results in a blue shade. This somehow boils down to creating a blue filter.
Page Index Toggle Pages: 1