Open
Description
In modules/img_hash/src/marr_hildreth_hash.cpp:getMHKernel(), the line reads
kPtr[col] = (2-a)*std::exp(a/2);
While it seems it should be
kPtr[col] = (2-a)*std::exp(-a/2);
At least that's what the original code does: https://github.com/aetilius/pHash/blob/master/src/pHash.cpp#L610
CImg<float> *GetMHKernel(float alpha, float level) {
int sigma = (int)4 * pow((float)alpha, (float)level);
static CImg<float> *pkernel = NULL;
float xpos, ypos, A;
if (!pkernel) {
pkernel = new CImg<float>(2 * sigma + 1, 2 * sigma + 1, 1, 1, 0);
cimg_forXY(*pkernel, X, Y) {
xpos = pow(alpha, -level) * (X - sigma);
ypos = pow(alpha, -level) * (Y - sigma);
A = xpos * xpos + ypos * ypos;
pkernel->atXY(X, Y) = (2 - A) * exp(-A / 2);
}
}
return pkernel;
}
And that also matches the formula given on wikipedia: https://en.wikipedia.org/wiki/Ricker_wavelet
Metadata
Metadata
Assignees
Labels
No labels