static float bwImageSimilarityResized_ignoreRatioMismatch(BWImage a, BWImage b, double similarityRequired) { int aw = a.w(), ah = a.h(); int bw = b.w(), bh = b.h(); int wp = max(aw, bw), hp = max(ah, bh); float ratio1 = ((float) aw)/ah, ratio2 = ((float) bw)/bh; float factor = wp*hp; float maxError = (1f-(float) similarityRequired)*factor; float diff = 0; for (int y = 0; y < hp; y++) for (int x = 0; x < wp; x++) { diff += Math.abs( a.getPixel(x*aw/wp, y*ah/hp)- b.getPixel(x*bw/wp, y*bh/hp)); if (diff > maxError) ret (float) similarityRequired-0.001f; } ret 1f-diff/factor; }