If anyone knows any ways of doing this using RGB ratios or
whatever I'd be very greatful. I need to be able to determine Yellow,
Green, Blue, Black, Red, and if possible light blue from dark blue :) I'll
be implementing the algorithm in java.
I have no experience with graphics work of this kind and have searched
newsgroup archives and search engines but cant find anything useful! Any
suggestions would be very greatfully received!
Thanks
Kemal Enver
u0...@dcs.shef.c.uk
> I need to be able to determine if the color of a pixel is a
> certain shade of a color. i.e. i might have the rgb values of a
> pixel - from this i need to determine if the pixel is a shade of a
> certain colour i.e. red or blue.
Sounds like a transformation to some other color coordinate system is
what you need. Try HSV or CIE Lab. See the Colour FAQ (posted here
regularly) for more details.
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
You should convert to HSV (hue, saturation, value) - the H part tells you
the basic colour, the S part the 'strength' of the colour, i.e. whether it's
a pastel shade or a pure colour, and the value part tells you how bright it
is.
> I have no experience with graphics work of this kind and have searched
> newsgroup archives and search engines but cant find anything useful! Any
> suggestions would be very greatfully received!
>
See e.g. http://www.cs.rit.edu/~ncs/color/t_convert.html
> Thanks
>
> Kemal Enver
> u0...@dcs.shef.c.uk
>
--
Roger
http://www.rops.org
You'll want to convert RGB into HSV.... Hue Saturation and Value. HSV
is also referred to as HSB (hue saturation and brightness). However,
we usually use HSV to refer to this color model so that the B's aren't
confused between Blue and Brightness. Here is how to convert RGB to
HSV...
// RGB to HSV:
max = Maximum(R, G, B);
min = Minimum(R, G, B);
V = max;
if (V != 0)
S = (V - min) / V;
else
S = 0;
if (S != 0)
{
if (V == R)
H = (G - B) / (max - min);
else if (V == G)
H = 2 + (B - R) / (max - min);
else if (V == B)
H = 4 + (R - G) / (max - min);
H *= 60; // Converts Hue to degrees.
if (H < 0)
H += 360; // Make Hue positive.
}
else
H = 0; // The hue is actually undefined if saturation and
value is zero.
Hue ranges from 0 to 359 degrees. Saturation ranges from 0 to 1. The
range of Value is the same as the range of the RGB values you started
with.
The easiest way to figure out what colors refer to which values of Hue
is to look at a color wheel. But, I can tell you that 0 degrees is
Red, 120 degrees is Green, and 240 degrees is Blue.
If you wanted to determine if a particular pixel is "Blue", for
instance, you could see if the Hue is between 180 and 270 degrees.
Note:180 degrees is Cyan.
This code was derived from that found in "Computer Graphics:
Principles and Practice, Second Edition in C."
-- Brian Stone
Kemal Enver
u0...@dcs.shef.ac.uk
You can set a threshold for saturation, below which you cannot identify the
hue. For me, on my monitor, this is S=20 out of 240. Then colors below this
threshold are black, gray, or white depending on the value of the remaining
component.
M.