Itseez/opencv — pull request #2545 by chrislgarry (2014-03-28 22:50:37+00:00)
Title: optimization of sigma precomputation. clarifying comments on what sig[] ...

We can see that, according to the original code :

sig[0] = sigma
sig[i] = sqrt(sig_total * sig_total - sig_prev * sig_prev )
= sqrt(sig_prev * sig_prev * k * k - sig_prev * sig_prev )
= sig_prev * sqrt( k * k - 1 )
= k^(i-1) * sigma * sqrt( k * k - 1 )

then:

sig[0] = sigma
sig[1] = sigma * sqrt( k * k - 1 )
sig[2] = k * sigma * sqrt( k * k - 1 ) = k* sig[1]
sig[3] = k^2 * sigma * sqrt( k * k - 1 ) = k* sig[2]

We can optimize as done in the PR.

I've also added clarifying comments because of a bug report that was incorrectly filed due to lack of commentary.