Warning: session_start(): open(/var/lib/php/sessions/sess_gbvfcpn1a1u04ggkgcvt9ajlmb, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
static float bwImageSimilarityResized(BWImage a, BWImage b, float similarity) {
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 mismatch = ratio1/ratio2;
if (mismatch < 1f) mismatch = 1f/mismatch;
float factor = wp*hp/mismatch; // ratio mismatch punishment (greater mismatch => factor smaller => returned difference bigger)
float maxError = (1f-similarity)*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 similarity-0.001f;
}
ret 1f-diff/factor;
}