Calculation of the mean value of an image is written in the following method. Although the example is written for grey level images, you can change the method for applying it to RGB images easily. You will just need to compute mean value for each channel (Red,Green or Blue channel). You can get pixel values of other channels by changing the third parameter of the getSample(x,y, channelNo) method of the Raster class.

     public static double meanValue(BufferedImage image) {
        Raster raster = image.getRaster();        
        double sum = 0.0;
        for (int y=0; y < image.getHeight(); ++y)
            for (int x=0; x < image.getWidth(); ++x)
                sum += raster.getSample(x,y,0);
        return sum / (image.getWidth() * image.getHeight());