this is my first question! The problem I'm trying to solve is: I'm creating a fingerprint pattern recognition program using OpenCV in C++. Following the paper I'm studying, I'm stuck on this part where it's said:
Compute the X-Signature array of values -> xSig[0, ..., w-1] (I've already done this part)
Compute the Power Spectrum, P[k], of the X-Signature where k=0 is the 0th harmonic and so on...
Now: the power spectrum I calculated is made by
Mat xSig = getxSig(); //ok
Mat fourier; //Fourier ARRAY made with Mat for convenience
Mat PS; //Power Spectrum, Mat for convenience
dft(xSig, fourier); //
pow(abs(fourier), 2, PS);
The problem is that the 0th harmonic on the Power Spectrum is always a lot bigger than the other harmonics and that let me think there is a problem on what I'm doing, or on what I know are the harmonics themselves. The xSignature arrays that I'm dealing with are very small (max 20 values) and I thought that maybe this is the cause of having such an high 0th harmonic.
The power spectrum should be calculated with this formula: PS = |Fourier| ^2 as said in this article, (formula extracted)
Here is an example of my calculated Power Spectrum from an xSignature: image
And also, this is an example if I put PS[0] = 0 for testing. This shows a large peak in the second harmonic, which I'm not quite sure of the meaning but seems more appropriate than a higher 0th harmonic...
EDIT:
Thanks to Ext3h for the reply, I managed to do this:
Mat planes[] = { Mat_<float>(xSig), Mat::zeros(xSig.size(), CV_32F) };
Mat complexI;
merge(planes, 2, complexI);
dft(complexI, complexI);
split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
Mat magI = planes[0];
which is actually copy pasted from the OpenCV guide and I got this. I enlarged the xSig array and also changed the way to compute the Power Spectrum. As you can see the Power Spectrum figure is correct but still there is that "spike" on the 0th harmonic that i don't think should be there, but is an improvement.