1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
File file1 = new File("screen11.jpg");
File file2 = new File("screen12.jpg");
try{
BufferedImage image1 = ImageIO.read(file1);
BufferedImage image2 = ImageIO.read(file2);
FileWriter fstream = new FileWriter("out2.txt");
BufferedWriter out = new BufferedWriter(fstream);
int columns = image1.getWidth();
int rows = image1.getHeight();
int total = columns * rows;
int cpt = 0;
for (int row=0; row<rows; row++){
for (int col=0; col<columns; col++){
int rgb = image1.getRGB(col, row);
int rgb2= image2.getRGB(col, row);
if(rgb != rgb2 && rgb != -1){
out.write(row+" "+col+" "+rgb+"\n");
//System.out.println(row+" "+col+" "+rgb);
cpt ++;
}
}
}
float percent = cpt * 100 / total;
System.out.println(cpt+" "+total+" "+percent+" %");
}catch(IOException e){} |
Partager