Here you can find the source of fuzzyEquals(BufferedImage a, BufferedImage b, int threshold)
public static boolean fuzzyEquals(BufferedImage a, BufferedImage b, int threshold)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { public static boolean fuzzyEquals(BufferedImage a, BufferedImage b, int threshold) { int aw = a.getWidth(); int ah = a.getHeight(); int bw = b.getWidth(); int bh = b.getHeight(); if ((aw != bw) || (ah != bh)) return false; for (int y = 0; y < ah; y++) for (int x = 0; x < bw; x++) { if (!fuzzyColorMatch(a.getRGB(x, y), b.getRGB(x, y), threshold)) { return false; }/*from ww w . j a va2s.c o m*/ } return true; } public static boolean fuzzyColorMatch(int color1, int color2, int threshold) { if (color1 == color2) return true; int difference = Math.abs((color1 & 0xFF) - (color2 & 0xFF)); if (difference > threshold) return false; difference += Math.abs((color1 >> 8 & 0xFF) - (color2 >> 8 & 0xFF)); if (difference > threshold) return false; difference += Math.abs((color1 >> 16 & 0xFF) - (color2 >> 16 & 0xFF)); if (difference > threshold) return false; difference += Math.abs((color1 >> 24 & 0xFF) - (color2 >> 24 & 0xFF)); return difference <= threshold; } }