# Detecting frequencies by 1D Fourier Transformation

What I want to do is to reconstruct frequencies out of a line of numbers. What I have is an array which I fill with values generated by f(x)= 4 * sin(0,5 * x) + 100 for test purposes. My goal is to get the frequency generated by the sinus-function with just the values in my array.

As far as I understand this is exactly what the fourier transformation does. So I used the code of the Discrete Fourier Transformation Tutorial from here http://docs.opencv.org/2.4/doc/tutori... and used the 1D-array as input (instead of a 2D picture). However I didn´t use image padding (line 13 - 16) and the rearrangement of the quadrants (!, line 33 - 52) from the tutorial to keep my code a little bit more simple. For example this is what I get:

Input: 80; 81; 83; 83; 83; 82; 80; 78; 76; 76; 76; 77; 78; 80; 82; 83; 83; 83; 81; 79; 77; 76; 76; 76; 77

Output: 1; 0.01; 0.49; 0.06; 0.08; 0.08; 0.13; 0.07; -3.72529e-09; 0.08; 0.11; 0.09; 0.10; 0.10; 0.09; 0.11; 0.08; 1.15484e-07; 0.07; 0.13; 0.08; 0.08; 0.06; 0.49; 0.01

The first value always seems to be 1 (regardless of what f(x) I use). As far as I know each number in the output represents a specific frequency and the value of the number determines how strong this frequency in the input was.

But how do I know which number in the frequency spectrum output belongs to which frequency? And why do I have often more than one high value in my output (i just use one sinus-function as input, so I exspected just one number in my output to have a high value)?

In other words: What to I have to do to get the searched frequency out of my fourier transformation output?

edit retag close merge delete

Sort by » oldest newest most voted

Hi, I suggest to try to understand the basics of the Fourier transform.

Anyway, from a signal of N samples, you'll get a Fourier transform of N samples.

The first component is the constant component (signal offset). The second component is the sinusoidal function which has a frequency of 1/N, or a period of N. The middle component (at N/2) denotes the frequency of 1/2, or a periode of 2. After, you'll get the mirror of the spectrum.

Note that the Fourier spectrum is complex.

more

Official site

GitHub

Wiki

Documentation