Question

In order to estimate the ridge frequency in a bloc of (32,16) pixels

I'm using the DFT of opencv : (where _frq is a vector that represents the sum of column of the bloc ..It has a sinosoide values form )

        cv::Scalar _mfrq= cv::mean(_frq);
        cv::subtract(_frq,_mfrq(0),_frq0);

        cv::dft(_frq0,_dft,cv::DFT_COMPLEX_OUTPUT);

        cv::split (_dft,_dfts);

        cv::magnitude(_dfts[0],_dfts[1],_dft_mag);

then I search for the index of the peak in _dft_mag which represents the frequency of ridges (somthing like the number of ridges in the bloc)

But It doesn't work ..After searching for the cause I found that the result of the DFT counts many INF values:

Here is an ex. of _frq :

[ 153,3248 , -31.154892 , -164.13715 , -183,20825 , -167.85382 , -88.419685 , 80.213303 , 209.28415 , 229.35269 , 179.00076 , 46.468304 , -94.168266 , -164.45575, -184.01825 , -172.35193 , -91.195152 , 29.647533 , 94.916519 , 76.251022 , 15.428349 , -14.313553, 5.5563583 , 82.969933 , 169.36349 ,152.70772 , 24.981915 , -113.6047 , -172.59244, 156.5137, -67.025078 , 98.894943 , 216.65082]

_dft_mag :

[1.52588789e-005 , 171.9715 , 965.74347 , 1640.5219 , 2210.7393 , 652.00055, 104.93217, 245.59544 , 186.00845, 196.77373 , 70.51609 , 44.303535 , 21.954809, 13.828483, 8.9678164 ,7.5699635 , 6.8006744 , 0 , nan, inf , inf , 0 , inf, nan , inf , 0 ,inf,inf ,nan, 0 , inf , inf]

after annalysing the result with the bloc I have the correct result had to be 4 ( wich correspond to 2210.7393 ).. and I had notice that the pb came from the imaginary part that was something like -2.4566e+038 in the cases where I had inf in the magnitude

Can any one explain me why I have this results and who to overcome this pb

Was it helpful?

Solution 2

I get It :D :D .. when using cv::dft We must use in input a 2-channel matrice ( that represents complex Matrice ) and we get in result the correct dft result as a 2-channels complex matrice also

OTHER TIPS

I think you can check first your dft for the block of 32 by 16 pixels or for whole. Just to see you getting the correct result. You can following the steps as per the opencv tutorial. I suspect you might to missing some data conversion or padding on the image boundary both these operations are required to correctly calculate the DFT. For more information please refer to this example. http://docs.opencv.org/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_transform.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top