This Java tip demonstrates how to get and set pixels in a buffered image. The pixels can be retrieved by using getRGB() function. Further, for setting the pixels setRGB() function may be used.

 // Firstly get a pixel (x.y may be defined by the developer)
    int rgb = bufferedImage.getRGB(x, y);
    // Developer may get all the pixels
    int w = bufferedImage.getWidth(null);
    int h = bufferedImage.getHeight(null);
    int[] rgbs = new int[w*h];
    bufferedImage.getRGB(0, 0, w, h, rgbs, 0, w);
    // Secondly set a pixel
    rgb = 0xFF00FF00; // green
    bufferedImage.setRGB(x, y, rgb);