0
votes

I have a photo which I load to a Bitmap. I checking color of some pixels. But in the picture sometimes something what should be for example red is a little bit more marron, magenta, orange etc, because of the light and other factors. I'm using method getPixel(x,y) which returns an int value of Color. Is any possibility to check if this int value is in interval which defines colors which are similar to red. Or is any website or something, where I can find any definitions or colors description?

2

2 Answers

1
votes

Yes. From http://developer.android.com/reference/android/graphics/Color.html, the Color integer is of the format 0xffRRGGBB. (The ff is actually an alpha channel, i.e. opacity, but is usually opaque hence ff).

There are many sites which will enable you to enter such values to get a look at the color - for example http://www.colourchart.net/. You could pick the outer bounds of each color component.

You might also consider using Color.colorToHSV() which will enable you to specify the bounds in terms of hue, saturation and brightness instead of red, green and blue - this may be logically easier in your context.

1
votes

Basicall RGB is not suitable for comparing colors, but there is a good color modell called HSV. So you should convert the RGB value to HSV then compare the Hue value of the colors with a threshold.

For example Hue value of the green color is 120, but you can accept the values between 90 and 150.

This link shows how to convert between the color modells: http://www.cs.rit.edu/~ncs/color/t_convert.html

More info about HSV modell: http://en.wikipedia.org/wiki/HSL_and_HSV