Getting Greyscale pixel value from RGB colourspace in Java using BufferedImage
Posted
by Andrew Bolster
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Bolster
Published on 2010-03-23T11:47:10Z
Indexed on
2010/03/23
11:53 UTC
Read the original article
Hit count: 573
Anyone know of a simple way of converting the RGBint value returned from <BufferedImage> getRGB(i,j)
into a greyscale value?
I was going to simply average the RGB values by breaking them up using this;
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
and then average red,green,blue.
But i feel like for such a simple operation I must be missing something...
© Stack Overflow or respective owner