1. 程式人生 > >離散傅立葉變換 The Discrete Fourier Transform (DFT)

離散傅立葉變換 The Discrete Fourier Transform (DFT)



The Discrete Fourier Transform (DFT)

The Java code to calculate the basic Discrete Fourier Transform can be found here in tar format. See the main Fourier transform page for a link to the tar program.

When I read that a DFT is calculated over a set of points, I expected that this referred to a sliding window over a larger data set. This incorrect assumption resulted from the fact that I came to Fourier analysis via wavelets, where a sliding window is used. In fact, the number of points refers to the data set over which the DFT is calculated. So if there are 64-points in the data, a 64-point DFT is calculated. The DFT algorithm is an N2

 algorithm, so computation time goes up rapidly with the number of points.

The DFT sums a set of cosine and sine functions scaled by the points in the data sample. I've tried to show this in the graphs below. These graphs have 17 data points (e.g., a 17-point DFT). The points are generated from the function sin(x)

. The sin(x) function and the data points are shown in red.

These graphs are displayed using gnuplot from data generated by the Java class dft_graph which can be down loaded here

The result of the DFT function, calculated over a range from 0..i is a set of complex objects. The mag() method will return the magnitude of the complex value. The magnitude graph for sin(x)

 is shown below. Only N/2 points are shown (in this case N is 17, so N/2 is 8). Only half of the points are graphed since the graph is symmetric and the next 8 points would mirror the first 8 points. The magnitude is adjusted to the same scale as the input signal, using the equation

   adjMag = (2 * mag)/N

Where N is the number of points in the DFT. Note that the magnitude of the sin(x) is 1.0. Since there is only one wave form, there should be only one magnitude. However, the peak magnitude shown in this graph is slightly less than 1.0 and there are smaller sub-magnitudes. This is an example of what Lyons calls "DFT leakage".

Two period sin(x)

Note that the largest magnitude line is at 2. The sample over which the DFT was calculated has two sine periods. If this were a sampled signal we could relate this to frequency. The magnitude graph below is from a sample with four sine periods. As with the magnitude plot above, only N/2 magnitudes are displayed, since the other half of the magnitude plot is symmetric.

Four period sin(x)

The interpretation of magnitude plots gets more obscure as the signal gets more complex. The function

f(x) = sin(2x) + sin(x) + sin(x/2)

is shown below.

The signal in this graph is made up of the sum of 8-periods from sin(2x), 4-periods from sin(x) and 2-periods from sin(x/2). The graph below shows magnitudes that result from the DFT of this signal (sorry, this version of the DFT graph is mislabeled).

Each of the large magnitude points above represents one of the frequency components of the signal. In absolute terms this frequency relates to the sample. The sample contains the sum of a two period sine wave, a four period sine wave and an eight period sine wave. The relationship between the sample frequency and the sampled signal depends on the sampling frequency. By including more signal periods in the sample, the DFT frequency goes up. For example, if the signal above is multiplied by four, we get the equation:

  f(x) = sin(8x) + sin(4x) + sin(2x)

Keeping the sampling region constant (0..25) on the x-axis yields a sample with four times as many periods. The graph is shown below (this version of the DFT graph is mislabeled).

Graphing the magnitudes that result from the DFT of this sample also shows the mangnitude frequencies increased by a factor of four as well.

Since the frequency of the DFT result is related to the sample, if the sample is reduced, so that there are only have two periods in the sample, the DFT result will show a lower frequency. The graph below shows f(x) = sin(8x) + sin(4x) + sin(2x), however the sample region is 0 ... ~6.25 (e.g., 2Pi)

The DFT magnitude result is plotted below. Note that this result is the same as

f(x) = sin(2x) + sin(x) + sin(x/2).

Postscript

I attempted to regenerate some of the graphs that I've displayed here in my web pages that discuss time/frequency analysis using wavelets. I noticed that the equations that I used to label the plots were incorrect. In particular where I should have written sin(8x) I wrote 8*sin(x). The discussion and the the plots of the sine functions are labeled correctly now, but the DFT plots are still incorrect. I hope that the reader will forgive this error.

Ian Kaplan, September 2001
Revised: April 2002

The Discrete Fourier Transform (DFT)

The Java code to calculate the basic Discrete Fourier Transform can be found here in tar format. See the main Fourier transform page for a link to the tar program.

When I read that a DFT is calculated over a set of points, I expected that this referred to a sliding window over a larger data set. This incorrect assumption resulted from the fact that I came to Fourier analysis via wavelets, where a sliding window is used. In fact, the number of points refers to the data set over which the DFT is calculated. So if there are 64-points in the data, a 64-point DFT is calculated. The DFT algorithm is an N2 algorithm, so computation time goes up rapidly with the number of points.

The DFT sums a set of cosine and sine functions scaled by the points in the data sample. I've tried to show this in the graphs below. These graphs have 17 data points (e.g., a 17-point DFT). The points are generated from the function sin(x). The sin(x) function and the data points are shown in red.

These graphs are displayed using gnuplot from data generated by the Java class dft_graph which can be down loaded here

The result of the DFT function, calculated over a range from 0..i is a set of complex objects. The mag() method will return the magnitude of the complex value. The magnitude graph for sin(x) is shown below. Only N/2 points are shown (in this case N is 17, so N/2 is 8). Only half of the points are graphed since the graph is symmetric and the next 8 points would mirror the first 8 points. The magnitude is adjusted to the same scale as the input signal, using the equation

   adjMag = (2 * mag)/N

Where N is the number of points in the DFT. Note that the magnitude of the sin(x) is 1.0. Since there is only one wave form, there should be only one magnitude. However, the peak magnitude shown in this graph is slightly less than 1.0 and there are smaller sub-magnitudes. This is an example of what Lyons calls "DFT leakage".

Two period sin(x)

Note that the largest magnitude line is at 2. The sample over which the DFT was calculated has two sine periods. If this were a sampled signal we could relate this to frequency. The magnitude graph below is from a sample with four sine periods. As with the magnitude plot above, only N/2 magnitudes are displayed, since the other half of the magnitude plot is symmetric.

Four period sin(x)

The interpretation of magnitude plots gets more obscure as the signal gets more complex. The function

f(x) = sin(2x) + sin(x) + sin(x/2)

is shown below.

The signal in this graph is made up of the sum of 8-periods from sin(2x), 4-periods from sin(x) and 2-periods from sin(x/2). The graph below shows magnitudes that result from the DFT of this signal (sorry, this version of the DFT graph is mislabeled).

Each of the large magnitude points above represents one of the frequency components of the signal. In absolute terms this frequency relates to the sample. The sample contains the sum of a two period sine wave, a four period sine wave and an eight period sine wave. The relationship between the sample frequency and the sampled signal depends on the sampling frequency. By including more signal periods in the sample, the DFT frequency goes up. For example, if the signal above is multiplied by four, we get the equation:

  f(x) = sin(8x) + sin(4x) + sin(2x)

Keeping the sampling region constant (0..25) on the x-axis yields a sample with four times as many periods. The graph is shown below (this version of the DFT graph is mislabeled).

Graphing the magnitudes that result from the DFT of this sample also shows the mangnitude frequencies increased by a factor of four as well.

Since the frequency of the DFT result is related to the sample, if the sample is reduced, so that there are only have two periods in the sample, the DFT result will show a lower frequency. The graph below shows f(x) = sin(8x) + sin(4x) + sin(2x), however the sample region is 0 ... ~6.25 (e.g., 2Pi)

The DFT magnitude result is plotted below. Note that this result is the same as

f(x) = sin(2x) + sin(x) + sin(x/2).

Postscript

I attempted to regenerate some of the graphs that I've displayed here in my web pages that discuss time/frequency analysis using wavelets. I noticed that the equations that I used to label the plots were incorrect. In particular where I should have written sin(8x) I wrote 8*sin(x). The discussion and the the plots of the sine functions are labeled correctly now, but the DFT plots are still incorrect. I hope that the reader will forgive this error.

Ian Kaplan, September 2001
Revised: April 2002

相關推薦

離散變換 The Discrete Fourier Transform (DFT)

The Discrete Fourier Transform (DFT) The Java code to calculate the basic Discrete Fourier Transform can be found here in tar format. Se

快速變換(Fast-Fourier Transform,FFT)

數學定義: (詳細參考:https://www.baidu.com/link?url=oYAuG2o-pia_U3DlF5n_MJZyE5YKfaVRUHTTDbM1FwM_kDTjGCxKpw_PbOK70jE2geVioprSVyPTTQuLwN-IhMH8NREmWSDnmcfQEY8w0kq&

數字影象處理筆記——二維離散變換(2D Discrete Fourier Transform

二維傅立葉變換 我們先來看看一維情況的傅立葉變換。在訊號系統中講過連續時間的傅立葉變換和離散時間的傅立葉變換,連續時間傅立葉變換在頻譜上時非週期的,離散時間傅立葉變換(DTFT)在頻譜上是週期的。在DSP中講了離散傅立葉變換,它的思想是將時域週期化,反映在頻域上就是對連續的週期頻譜進行抽樣

(一)連續變換離散變換級數(Fourier Series)

訊號的正交分解到傅立葉級數(FS)一、訊號分解為正交函式二、傅立葉級數的三角形式由(一)可知,可將一個週期為T的訊號f(T),在(t0,t0+T)內表示為三角函式集的線性組合,即:上式即為週期訊號f(t),在區間(t0,t0+T)內的三角傅立葉級數展開式。Ω=2π/T稱為基波

離散變換DFT)和快速變換(FFT)原理與實現

目錄 1、影象變換 2、離散傅立葉變換(Discrete Fourier Transform) 3、DFT性質 4、DFT與數字影象處理 5、FFT-快速傅立葉變換 6、DFT與FFT的演算法實現 1. 影象變換 — —數學領域中有很多種變換,如傅立葉變換、拉普拉斯變

c語言數字影象處理(六):二維離散變換

基礎知識 複數表示 C = R + jI 極座標:C = |C|(cosθ + jsinθ) 尤拉公式:C = |C|ejθ 有關更多的時域與複頻域的知識可以學習複變函式與積分變換,本篇文章只給出DFT公式,性質,以及實現方法 二維離散傅立葉變換(DFT) 其中f(x,y)為原影象,F(u,

拉普拉斯變換變換;Z變換離散時間變換(DTFT);離散變換DFT)之間的關係及理解

頻域與時域之間的關係是: 時域離散——頻域週期; 時域週期——頻域離散; 對於連續時間訊號 1.拉普拉斯變換: X (

Python中使用numpy對序列進行離散變換DFT

看了大佬對DFT的介紹後感覺離散傅立葉變換對序列訊號的處理還是很有用的, 總結下來就是DFT可以增加有限長序列的長度來提高物理解析度。 自己用python中的numpy庫實現了一下: 其中繪相簿的使用請參考:Python繪圖 將有效長度為4的單位序列,變換為長度16的DFT譜線。

補零與離散變換的解析度

     離散傅立葉變換(DFT)的輸入是一組離散的值,輸出同樣是一組離散的值。在輸入訊號而言,相鄰兩個取樣點的間隔為取樣時間Ts。在輸出訊號而言,相鄰兩個取樣點的間隔為頻率解析度fs/N,其中fs為取樣頻率,其大小等於1/Ts,N為輸入訊號的取樣點數。這也就是說,DF

二維離散變換以及濾波應用

一、二維離散傅立葉變換 二維離散傅立葉變換的公式:F(u,v)=1MN[∑m=0M−1∑n=0N−1f(m,n)WMumWNvn]∙RMN(u,v) F(u,v) = \frac{1}{MN}[\sum_{m=0}^{M-1}\sum_{n=0}^{N-1}f

《OpenCV3程式設計入門》——5.5.8 離散變換綜合示例程式(附程式碼)

綜合《OpenCV3程式設計入門》——5.5 離散傅立葉變換原理和 《OpenCV3程式設計入門》——5.5.2 離散傅立葉變換相關函式詳解兩篇文章對離傅立葉變換的詳細介紹,本篇將展示實現離散傅立葉變化的示例程式(本篇所涉及的所有知識均在上述兩篇博文裡有詳細解釋,請參考): //--------

《OpenCV3程式設計入門》——5.5.2 離散變換相關函式詳解

目錄 1、dft()函式 2、返回DFT最優尺寸大小:getOptimalDFTSize()函式 3、擴充影象邊界:copyMakeBorder()函式 4、計算二維向量的幅值:magnitude()函式 6、矩陣歸一化:normalize()函式 1、dft()函式

《OpenCV3程式設計入門》——5.5 離散變換原理

離散傅立葉變換(Discrete Fourier Transform,縮寫為DFT)指傅立葉變換在時域和頻域上都呈現離散的形式,將時域訊號的取樣變換為在離散時間傅立葉變換(DTFT)頻域的取樣。 形式上,變換兩端(時域和頻域)的序列是有限長的,而實際上這兩組序列都應該被認為是離散週期訊號的主值序

離散變換在影象處理中的應用_學習

1、為什麼要進行傅立葉變換,其物理意義是什麼? 傅立葉原理表明:任何連續測量的時序或訊號,都可以表示為不同頻率的正弦波訊號的無限疊加。而根據該原理創立的傅立葉變換演算法利用直接測量到的原始訊號,以累加方式來計算該訊號中不同正弦波訊號的頻率、振幅和相位。 和傅立葉

OpenCV中對影象進行二維離散變換

#include<opencv2/opencv.hpp> #include <highgui.h> #include <iostream> #include <cv.h> #include <opencv2/core/c

OpenCV學習筆記(六)離散變換

離散傅立葉變換: 傅立葉變換將講時域訊號分解為不同頻率的正弦訊號或餘弦訊號疊加之和,時域分析只能反映訊號的幅值隨時間變化得情況,除單頻率分量的簡諧波外,很難對資訊頻率的組成及各頻率分量的大小進行詳細分析,而訊號頻譜分析提供了比時域訊號波形更直觀、更豐富的資訊。在實際的影象處

在二維離散變換中進行頻譜平移(MATLAB::fft2shift)的作用

 懶得自己敲文字描述了,直接摘取在一個資料上看到的截圖吧! ------------------------------------------- 影象處理開發資料、影象處理開發需求、影象

離散變換DFT

用途:將一組時域訊號變換到頻域,分析該訊號中各頻率分量。 效果:長度為n的數列x 的DFT是另一組長度為n的數列y yp+1=∑j=0n−1ωjpxj+1 其中,ω=e−2πi/n,p∈[0,n−

C++實現二維離散變換

在上一篇文章《C++實現一維離散傅立葉變換》中,我們介紹了一維訊號傅立葉變換的公式和C++實現,並闡述了頻域幅值的意義。 一維傅立葉變換只適用於一維訊號,例如音訊資料、心腦電圖等。 在影象處理中,影象訊號具有高度和寬度兩個屬性,屬於二維空間訊號。將影象訊號從空間域轉換到頻域

影象變換(二維離散變換

影象傅立葉變換 二維離散傅立葉變換是將影象從空間域轉至頻域,在影象增強、影象去噪、影象邊緣檢測、影象特徵提取、影象壓縮等等應用中都起著極其重要的作用。理論基礎是任意函式都可以表示成正弦函式的線性組合的形式。公式如下 逆變換公式如下 令 R(u,v) 和 I(u,c) 分別表示 F