我已经制作了这个方法,它获取红色,绿色和蓝色的值并将它们存储在temp int中,然后将该int添加到数组中。我希望在不合并它们的情况下组合这些值,但我不确定如何?
public static double[] GetHistogram (BufferedImage img) {
double[] myHistogram = new double [256];
int Temp = 0;
int Temp1 = 0;
int Temp2 = 0;
for (int y = 0; y < img.getHeight(); y += 1)
{
for (int x = 0; x < img.getWidth(); x += 1)
{
int clr = img.getRGB(x,y);
int red = (clr & 0x00ff0000) >> 16;
int green = (clr & 0x0000ff00) >> 8;
int blue = clr & 0x000000ff;
Temp = 0;
Temp1 = 0;
Temp2 = 0;
Temp += red;
Temp1 += green;
Temp2 += blue;
Temp = (int) Temp;
myHistogram[Temp]++;
myHistogram[Temp1]++;
myHistogram[Temp2]++;
}
}
return myHistogram;
}