#include "lib/lib.h"
#include "lib/math.h"
+#include "images/math.h"
#include "images/images.h"
#include "images/signature.h"
#include <stdio.h>
/* Compute distance matrix */
for (uns i = 0; i < cnt1; i++)
- for (uns j = i + 1; j < cnt2; j++)
+ for (uns j = 0; j < cnt2; j++)
{
uns d = 0;
for (uns k = 0; k < IMAGE_REG_F; k++)
f = MIN(f, mf[i][j]);
h = MIN(h, mh[i][j]);
}
- lf[i] = (df * 0x10000) / (df + (int)sqrt(f));
- lh[i] = (dh * 0x10000) / (dh + (int)sqrt(h));
+ lf[i] = (df * 0x10000) / (df + fast_sqrt_u32(f));
+ lh[i] = (dh * 0x10000) / (dh + fast_sqrt_u32(h));
lfs += lf[i] * (6 * reg1[i].wa + 2 * reg1[i].wb);
lhs += lh[i] * reg1[i].wa;
}
f = MIN(f, mf[j][i]);
h = MIN(h, mh[j][i]);
}
- lf[i + cnt1] = (df * 0x10000) / (df + (int)sqrt(f));
- lh[i + cnt1] = (dh * 0x10000) / (dh + (int)sqrt(h));
+ lf[i + cnt1] = (df * 0x10000) / (df + fast_sqrt_u32(f));
+ lh[i + cnt1] = (dh * 0x10000) / (dh + fast_sqrt_u32(h));
lfs += lf[i] * (6 * reg2[i].wa + 2 * reg2[i].wb);
lhs += lh[i] * reg2[i].wa;
}
DBG("measure=%.4f", measure / (double)(1 << (3 + 3 + 8 + 16)));
#endif
- return measure;
+ return (1 << (3 + 3 + 8 + 16)) - measure;
}