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.