I am dealing with images and would like to determine if a set of pixels are closer to white or black.
So given a set of colors/pixles, how does one det
There are two potential meanings of white and black:
The former is easy: convert to greyscale range 0-255. 127 or less is closer to black (0), 128 or above is closer to white (255).
I use the following function to convert to greyscale using luminance values (assuming an int ARGB format for input colour):
public static int getLuminance(int argb) {
int lum= ( 77 * ((argb>>16)&255)
+ 150 * ((argb>>8)&255)
+ 29 * ((argb)&255))>>8;
return lum;
}
The latter definition (human skin tones) is impossible to do with a simple algorithm as it depends on light condition, camera settings, exposure etc. An RGB vlaue of (190,115,60) is probably approximately the midpoint in typical conditions