I am using this method to calculate the mean pixel value of an image. Is there a better or more complex way of doing this particular method?I am pretty new to this and I am happy that I have got this far but I have been tasked with finding a better, more mathematically complex way of doing this and I am stumped!
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());
}