Does anyone know a simple way to convert the RGBint value returned from <BufferedImage> getRGB(i,j) to a grayscale value?
I was going to just average the RGB values, splitting them using this:
int alpha = (pixel >> 24) & 0xff; int red = (pixel >> 16) & 0xff; int green = (pixel >> 8) & 0xff; int blue = (pixel) & 0xff;
and then medium red, green, blue.
But I feel that something is missing for such a simple operation ...
After an excellent answer to another question, I have to clarify what I want.
I want to take the RGB value returned from getRGB (i, j) and turn it into a white value in the range 0-255, representing the "Darkness" of this pixel.
This can be achieved by averaging, etc., but I am looking for an OTS implementation to save multiple lines.
source share