code: public final double getRed(int x, int y) {
          int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
          int idx = x + y * width;
  
          return (pixels[idx] >> 16 & 0x000000ff);
      }
docs: Returns the red color value of the pixel data in this Image.
  
  @param x
  The x-coordinate of the pixel.
  @param y
  The y-coordinate of the pixel.
  @return
  The red color value of the pixel.