public void Diff() throws IOException {
BufferedImage image1 = ImageIO.read(new File("coloured-pencils.jpg"));
BufferedImage image2 = ImageIO.read(new File("happy.jpg"));
BufferedImage image3 = new BufferedImage(image1.getWidth(), image1.getHeight(), image1.getType());
int img1H = image1.getHeight();
int img1W = image1.getWidth();
int img2H = image2.getHeight();
int img2W = image2.getWidth();
int argb1, alpha1, red1, green1, blue1;
int argb2, alpha2, red2, green2, blue2;
int aDiff, rDiff, gDiff, bDiff;
int diff;
if (img1H == img2H && img1W == img2W) {
for (int x = 0; x < image1.getHeight(); x++) {
for (int y = 0; y < image1.getWidth(); y++) {
argb1 = image1.getRGB(x, y);
argb2 = image2.getRGB(x, y);
alpha1 = (argb1 >> 24) & 0xFF;
red1 = (argb1 >> 16) & 0xFF;
green1 = (argb1 >> 8) & 0xFF;
blue1 = (argb1) & 0xFF;
alpha2 = (argb2 >> 24) & 0xFF;
red2 = (argb2 >> 16) & 0xFF;
green2 = (argb2 >> 8) & 0xFF;
blue2 = (argb2) & 0xFF;
aDiff = Math.abs(alpha1 - alpha2);
rDiff = Math.abs(red1 - red2);
gDiff = Math.abs(green1 - green2);
bDiff = Math.abs(blue1 - blue2);
diff = (aDiff << 24) | (rDiff << 16) | (gDiff << 8) | bDiff;
image3.setRGB(x, y, diff);
}
}
this.setOriginalImage(image3);
} else {
}
}