据我了解,此方法将获得图像中每个红色像素的平均亮度值。这是正确的吗? java的颜色类是否具有这样做的能力,或者这只会返回图像中平均红色像素数?
/*Mean Red*/
public static double meanValueRed(BufferedImage image) {
double sum = 0.0;
for (int y = 0; y < image.getHeight(); ++y){
for (int x = 0; x < image.getWidth(); ++x){
Color r = new Color(image.getRGB(x, y));
sum += r.getRed();
}
}
return sum / (image.getWidth() * image.getHeight());
}