String str = "2.jpg";
File f = new File(str);
try {
BufferedImage image2 = ImageIO.read(f);
int w = image2.getWidth();
int h = image2.getHeight();
int[] arr = image2.getRGB(0, 0, w, h, null, 0, w);
int[][] xy = new int[h][w];
for(int i = 0;i
for(int k=0;k
xy[i][k] = arr[i*k+k];
}
}
int th =0;
int tw =0;
for(int i = 0;i
for(int k=0;k
th =i+1;
tw = k+1;
if((th == h)) {
th = h-1;
}
if((tw == w)) {
tw = w-1;
}
int temp1 = xy[Math.abs(i-1)][k] -xy[i][k];
int temp2 = xy[th][k] -xy[i][k];
int temp3 = xy[i][Math.abs(k-1)] -xy[i][k];
int temp4 = xy[i][tw] -xy[i][k];
xy[i][k] =(int)(xy[i][k] + (temp1+temp2+temp3+temp4)/4);
}
;
}
for(int i = 0;i
for(int k=0;k
arr[i*k+k]=xy[i][k] ;
}
}
image2.setRGB(0, 0, w, h, arr, 0, w);
ImageIO.write(image2, "jpg", new File("22.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}