Questions tagged [dft]

Discrete Fourier transform (DFT) is a specific kind of discrete transform, used in Fourier analysis.

Given a sequence of N samples f(n), indexed by n = 0..N-1, the discrete Fourier transform (DFT) is defined as F(k), where k=0..N-1:

Enter image description here

Source: engineeringproductivitytools

428 questions
3
votes
2 answers

Cooley Tukey twiddle factor in a simple python script

I'm reading how the cooley tukey method works, but I have a few problems with the following python script: def fft_CT_twiddles(x, inverse = False, verbose = False, twiddles = None) : """ Computes the DFT of x using Cooley-Tukey's FFT…
Marco A.
  • 43,032
  • 26
  • 132
  • 246
3
votes
1 answer

How to select frequencies from DFT

Assume a sequence of numbers (wave-like data). I perform then the DFT (or FFT) transform. Next step I want to achieve is to find the frequencies, that correspond to the real frequencies that are included in data. As we know, DFT output has real and…
maximus
  • 4,201
  • 15
  • 64
  • 117
3
votes
1 answer

How to calculate the energy per bin in a DFT?

I am testing my knowledge about Discrete Fourier Transforms. What I am testing now is how to calculate the central frequency of a wave using DFT. For that purpose I create a sinusoidal data using this code: // create a 100 Hz wave with a sampling…
Duck
  • 34,902
  • 47
  • 248
  • 470
3
votes
1 answer

Two dimensional FFT using python results in slightly shifted frequency

I know there have been several questions about using the Fast Fourier Transform (FFT) method in python, but unfortunately none of them could help me with my problem: I want to use python to calculate the Fast Fourier Transform of a given two…
Alienbash
  • 554
  • 7
  • 17
3
votes
1 answer

Python: Finding period of a two column data

This question seems so trivial but I didn't find any suitable answer so I am asking! Lets say I have a two column data(say, {x, sin(x)} ) X Y(X) 0.0 0.0 0.1 0.099 0.2 0.1986 How do I find the period of the function Y(X); I have some experience in…
Archimedes
  • 365
  • 3
  • 15
3
votes
1 answer

OpenCV DFT-based convolution is shifted

I tried implementing image filtering in spectrum based on this OpenCV example from the docs and copied for convenience here: void convolveDFT(InputArray A, InputArray B, OutputArray C) { C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1,…
pseudomarvin
  • 1,477
  • 2
  • 17
  • 32
3
votes
1 answer

fft2 in MATLAB vs dft in OpenCV C++ speed comparison

I'm wondering why the dft function in OpenCVC++ is a lot slower than fft2 for 2D matrices. The following C++ code is from the documentation: void fft2(const Mat in, Mat &complexI) { Mat padded; int m = getOptimalDFTSize(in.rows); int n…
smttsp
  • 4,011
  • 3
  • 33
  • 62
3
votes
4 answers

Fourier Transform: Computational Scaling as a function of vector length

If I were to use the following defined function to compute a discrete Fourier transform, how would I show that the computation scales as O(N^2) as a function of vector length. def dft(y): N = len(y) c = np.zeros(N//2+1,complex) …
rall
  • 43
  • 3
3
votes
1 answer

Discrete Fourier Transform implementation gives different result than OpenCV DFT

We have implemented DFT and wanted to test it with OpenCV's implementation. The results are different. our DFT's results are in order from smallest to biggest, whereas OpenCV's results are not in any order. the first (0th) value is the same for…
Silex
  • 2,583
  • 3
  • 35
  • 59
3
votes
1 answer

Simple and efficient algorithm to detect frequency and phase of a sine signal

I need an algorithm to detect frequency and phase of a pure sine signal. The frequency of the input signal changes between 0 and 100 Hz. The value of the signal gets captured with a frequency of 20kHz (so I get 20.000 values per second) - this is…
3
votes
2 answers

FFTW simply will not return values other than infinity, values that approach zero, or negative infinity

I am trying to calculate the DFT of a sine wave at 20hz. First I fill a std::vector with 10 cycles of the sine function at 20 hz: std::vector sinx; double samplerate = 1000.0; double frequency = 20.0; double num_cycles = 10.0; for (int i=0;…
sugarmuff
  • 435
  • 5
  • 17
3
votes
2 answers

STFT/FFT work flow order

I am trying to implement FFT, and I am OK with the code etc, but the general order of things is confusing me. Am I right in thinking that this is the correct order of things to do? Input -> Overlap input -> Windowing -> FFT -> Phase…
jacob
  • 31
  • 1
  • 4
3
votes
1 answer

OpenCV DFT_INVERSE different from Matlab's ifft

I try to filter a signal using opencv's dft function. The way I try to this is taking the signal in time domain: x = [0.0201920000000000 -0.0514940000000000 0.0222140000000000 0.0142460000000000 -0.00313500000000000 0.00270600000000000…
CRS
  • 109
  • 4
  • 15
3
votes
0 answers

How to get FFT units for spatial 1D signal?

Note : Answers with dimensions (cy/mm) instead of (Hz) would be greatly appreciated! I have looked into unit of fft(DFT) x axis and units on x axis after FFT , but I couldn't find exactly what I'm looking for. So, I decided to write my own…
mxy
  • 331
  • 2
  • 9
3
votes
4 answers

Calculating nth Roots of Unity in Python

So, I'm trying to write an algorithm croot(k, n), that returns the kth root of unity with n == n. I'm getting mostly the right answer, however it's giving me really weird representations that seem wrong for certain numbers. Here is an…
robins35
  • 653
  • 12
  • 37