Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong equations in Zero-mean SSD #32

Open
ghost opened this issue May 10, 2013 · 0 comments
Open

Wrong equations in Zero-mean SSD #32

ghost opened this issue May 10, 2013 · 0 comments

Comments

@ghost
Copy link

ghost commented May 10, 2013

I have been checking the Zero-mean SSD equations in matcher.cpp:

// sum[ ((A-mean(A)) - (B-mean(B))^2 ]
// = sum[ ((A-B) - (mean(A)-mean(B))^2 ]
// = sum[ (A-B)^2 - 2(A-B)(mean(A)mean(B)) + (mean(A)-mean(B))^2 ]
// = sum[ (A-B)^2 ] - 2(mean(A)mean(B))(sumA-sumB) + N(mean(A)-mean(B))^2
// = sum[ (A-B)^2 ] - N * (mean(A)-mean(B))^2
// = sum[ A^2-2AB-B^2 ] - 1/N * (sumA-sumB)^2
// = sumAA-2_sumAB-sumBB - 1/N * (sumA^2-2_sumA_sumB-sumB^2)
*znssd = sumAA-2_sumAB-sumBB - (sumA_sumA - 2_sumA_sumB - sumB_sumB)/BOX_AREA;

This code seems to work but the equations are wrong, there are two mistakes:

(A-B)^2 -> A^2-2AB-B^2
------------> A^2-2AB+B^2

(sumA-sumB)^2 -> sumA^2-2_sumA_sumB-sumB^2
-------------------------> sumA^2-2_sumA_sumB+sumB^2

So, znssd should be calculated this way:

_znssd = sumAA-2_sumAB+sumBB - (sumA_sumA - 2_sumA_sumB + sumB_sumB)/BOX_AREA;

Regards

@JzHuai0108
Copy link

I AGREE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant