我有一套气象RGB类型BufferedImage
s。我想获得他们的平均形象。由此,我的意思是获得每个像素的平均值,并从这些值中创建一个新图像。我试过的是:在java中获取一组图像的平均图像
public void getWaveImage(BufferedImage input1, BufferedImage input2){
// images are of same size that's why i'll use first one's width and height
int width = input1.getWidth(), height = input1.getHeight();
BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
int[] rgb1 = input1.getRGB(0, 0, width, height, new int[width * height], 0, width);
int[] rgb2 = input2.getRGB(0, 0, width, height, new int[width * height], 0, width);
for(int i=0; i<width; i++){
for(int j=0; j<height; j++){
int rgbIndex = i * width + j;
rgb1[rgbIndex] = (rgb1[rgbIndex] + rgb2[rgbIndex])/2;
}
}
output.setRGB(0, 0, width, height, rgb1, 0, width);
return output;
}
我在做什么错了?先谢谢你。
输入1:
输入2:
输出:
首先定义你的平均含义...... – Tschallacka
我不认为使用''rgb1 [rgbIndex] + rgb2 [rgbIndex])/ 2''会给你两种输入颜色之间的颜色。 – f1sh
@Tschallacka对不起,我现在添加了。 – halil