You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have not checked this against the code yet, but in 6.1.5.4 we see strange formulas.
The usual explanation for the ridge flow computation is to compute the local gradient at each pixel (f_x anf f_y), then, purely for mathematical purposes, combine that into an imaginary number:
g = f_x + i f_y = R e^{i\phi}
The reason for this is that we actually do not care if the gradient is from light to dark, or from dark to light, so \phi and \phi+180° should be considered the same orientation. Simple example:
||||||| <- is the maximum gradient from left to right or from right to left?
The easiest way to achieve this is multiplying the angle by two: 2\phi = 2(\phi+180°) = 2\phi + 360° = 2\phi
And imaginary numbers have the nice property that squaring the number doubles the angle, so we get:
common_functions.cpp:L240 evaluates equations (9)-(12). Whether those are correct depends on the value provided for c, so we need to look at the position that calls NFIQ2::QualityMeasures::ridgeorient().
Looking at the definition of covcoef() in common_functions.cpp:L151 I can see that c is indeed calculated as in (7), so a factor of 2 is missing from all of the above usages, or, alternatively, the definition of ridgeorient()
Have not checked this against the code yet, but in 6.1.5.4 we see strange formulas.
The usual explanation for the ridge flow computation is to compute the local gradient at each pixel (f_x anf f_y), then, purely for mathematical purposes, combine that into an imaginary number:
g = f_x + i f_y = R e^{i\phi}
The reason for this is that we actually do not care if the gradient is from light to dark, or from dark to light, so \phi and \phi+180° should be considered the same orientation. Simple example:
||||||| <- is the maximum gradient from left to right or from right to left?
The easiest way to achieve this is multiplying the angle by two: 2\phi = 2(\phi+180°) = 2\phi + 360° = 2\phi
And imaginary numbers have the nice property that squaring the number doubles the angle, so we get:
g^2 = R^2 e^{i 2\phi} = (f_x + i f_y)^2 = (f_x^2 - f_y^2) + i (2 f_x f_y) = R^2 + e^{i 2 \phi}
so calculating the mean of all these (squared) gradients results in
\overbar(g^2} = \overbar{f_x^2} - \overbar{f_y^2} + i 2 \overbar{f_x f_y} = R'^2 e^{i 2 \phi'}
or, using equations (5), (6), and (7)
\overbar{g^2} = a-b + i 2c = \sqrt{(a-b)^2+4c^2} e^{i \atan(2c/(a-b))}
or R = \sqrt{(a-b)^2+4c^2}
which is nearly (9), except for the factor 4, and
\phi = 1/2\atan(2c/(a-b))
which is nearly (12), except for the factor 2.
(10) and (11) aren't actually needed, but if we wanted to use them, they had to be
\sin(\theta)=2c/R
\cos(\theta) = (a-b)/R
and (8) will be only needed later, but this is the scatter matrix of the gradient and is, I believe, correct.
BTW, in (13) and (14), which use (8), you will see that \lambda = ((a+b)\pm R)/2,
and calculating the eigenvectors from the eigenvalues given in (13) and (14) and using the identity
\tan(2a) = 2\tan(a)/(1-\tan^2(a))
you would ultimately arrive at the same angle.
The text was updated successfully, but these errors were encountered: