One thing that comes to mind is possibly converting each of the color triplets into HSV color space and indexing them based on Hue... if you are not interested in the saturation or brightness of the color, but rather whether its there or not. Though there is no standard for the conversion most seem to use the following for conversion:
in reply to multi-dimensional range lookup
just a thought... perhaps a CPAN module in the making eh?
V = max (r,g,b)
S = (max (r,g,b)) - min (r,g,b)/max (r,g,b)
H = depends on which of r,g,b is the maximum
where r,g,b are your 0 - 255 values.
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo