Here you can find the source of compareImages(BufferedImage imageOne, BufferedImage imageTwo)
public static double compareImages(BufferedImage imageOne, BufferedImage imageTwo)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { public static double compareImages(BufferedImage imageOne, BufferedImage imageTwo) { int useWidth = imageOne.getWidth() > imageTwo.getWidth() ? imageTwo.getWidth() : imageOne.getWidth(); int useHeight = imageOne.getHeight() > imageTwo.getHeight() ? imageTwo.getHeight() : imageOne.getHeight(); int maxWidth = imageOne.getWidth() < imageTwo.getWidth() ? imageTwo.getWidth() : imageOne.getWidth(); int maxHeight = imageOne.getHeight() < imageTwo.getHeight() ? imageTwo.getHeight() : imageOne.getHeight(); int differenceCount = 0; for (int x = 0; x < useWidth; x++) { for (int y = 0; y < useHeight; y++) { if (imageOne.getRGB(x, y) != imageTwo.getRGB(x, y)) differenceCount++;/* w w w. j a v a 2s.c om*/ } } return differenceCount / (useWidth * useHeight) + ((maxWidth * maxHeight) - (useWidth * useHeight)); } }