The value that is obtained with image.getRGB(x,y)
is an int
that consists of the three color components Red, Green and Blue, each having 8 bit. The Alpha value is fixed as 255 when the image does not contain transparency.
When the image is a grayscale image, the Red, Green and Blue components of this RGB value will be all equal. So you can obtain the "gray" value as
int rgb = image.getRGB(x,y);
// This yields a value between 0 (black)
// and 255 (white) :
int gray = rgb & 0xFF;