Fourier Transform
基本的定义
严格来说, 傅里叶变换是Schwartz space 上的一一映射, 对于\(L^1\), 即可积函数我们都可以找到其对应的傅里叶变换.
符号 | 定义 |
---|---|
傅里叶变换: \(\hat{f}(u)\) | \(\int_{-\infty}^{+\infty} f(t) e^{-j2\pi u t} \mathrm{d}t\) |
逆傅里叶变换: \(\check{F}(t)\) | \(\int_{-\infty}^{+\infty} F(u) e^{j2\pi tu} \mathrm{d}u\)? |
离散傅里叶变换: \(F_m=\hat{f}_m\) | \(\sum_{n=0}^{N-1} f_n e^{-j2\pi nm/N}\)? |
离散逆傅里叶变换: \(f_n = \check{F}_n\) | \(\frac{1}{N}\sum_{m=0}^{N-1} F_m e^{j2\pi mn /N}\) |
卷积: \(f \star g (t)\) | \(\int_{-\infty}^{+\infty} f(\tau) g(t-\tau) \mathrm{d}\tau\) |
correlation: \(f \bullet g(t)\)? | \(\int_{-\infty}^{+\infty}f^*(\tau)g(\tau + t)\mathrm{d}\tau\) |
二元傅里叶变换: \(\hat{f}(u, v)\) | \(\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(t, z) e^{-j2\pi ut} e^{-j2\pi vz} \mathrm{d}t \mathrm{d}z\) |
二元傅里叶逆变换: \(\check{F}(t, z)\) | \(\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} F(u, v) e^{j2\pi tu} e^{-j2\pi zv} \mathrm{d}t \mathrm{d}z\) |
二元卷积: \(f \star g (t, z)\) | \(\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(\tau, \omega) g(t - \tau, z - \omega) \mathrm{d}\tau \mathrm{d}\omega\) |
共轭 | \(f^*(t) = [r(t) + j i(t)]^* = r(t) - ji(t), \quad r(t), i(t) \in \mathbb{R}\) |
注: 不同版本的傅里叶变换的定义存在系数上的差异.
性质
\(\hat{}\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(\check{}\) | |
---|---|---|---|
1 | \(f(t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u)\) |
2 | \(f \star g (t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) \cdot G (u)\) |
3 | \(f \bullet g(t)\)? | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F^*(u) \cdot G(u)\) |
4 | $f(t) \cdot g(t) $ | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F \star G (u)\) |
5 | \(f(t) + g(t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) + G(u)\) |
6 | \(f(t + t_0)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(e^{j2\pi t_0 u} F(u)\) |
7 | \(f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(-u)\) |
8 | \(F(u)=\hat{f}(u)\)? | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(f(-t) = \hat{\hat{f}}(t)\) |
以上 | 对于 | 离散 | 成立 |
9 | \(f(at)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | $\frac{1}{ |
10 | \(f‘(t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(j2\pi u F(u)\) |
11 | \(-j2\pi tf(t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F‘(u)\) |
12 | \(f(R \mathbf{t})\), \(R^TR=I\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(R\mathbf{u})\) |
注: 虽然以上性质除11外都是用了标量, 但是实际上对于一般的傅里叶变换也是成立的.
-
pass
-
卷积:
\[\begin{array}{ll} (f \star g)^{\hat{}}(u) &= \int f \star g (t) e^{-j2\pi u t} \mathrm{d}t \&= \int \int f(t-\tau) g (\tau) \mathrm{d}\tau e^{-j2\pi u t} \mathrm{d}t \&= \int \int f(t-\tau) g (\tau) e^{-j2\pi u t} \mathrm{d}t \mathrm{d}\tau \quad \rightarrow \mathrm{Fubini}\&= \int \int f(t-\tau) e^{-j2\pi u (t-\tau)} \mathrm{d}t \: g(\tau)e^{-j2\pi u\tau} \mathrm{d}\tau \quad \&= F(u) \cdot G(u). \end{array} \]\(\Leftarrow\)是类似的证明.
-
correlation:
\[\begin{array}{ll} (f \bullet g)^{\hat{}}(u) &= \int f*g(t) e^{-j2\pi ut} \mathrm{d}t \&= \int \int f^*(\tau) g(\tau + t) \mathrm{d}\tau e^{-j2\pi ut} \mathrm{d}t \&= \int f^*(\tau) \int g(\tau + t) e^{-j2\pi ut} \mathrm{d}t \mathrm{d}\tau \&= G(u)\int f^*(\tau) e^{j2\pi u\tau} \mathrm{d}\tau \&= G(u)[\int f(\tau) e^{-j2\pi u\tau} \mathrm{d}\tau]^* \&= F^*(u)G(u) \end{array} \] -
乘积的证明和上面是一样的, 无非是作用于\(\check{}\)上.
-
pass
-
平移:
\[(f(t+t_0))^{\hat{}} = \int f(t+t_0) e^{-j2\pi ut} \mathrm{d}t =e^{j2\pi u t_0}\int f(t+t_0) e^{-j2\pi u(t+t_0)} \mathrm{d}t = e^{j2\pi t_0u} F(u). \] -
逆:
\[(f(-t))^{\hat{}} = \int f(-t) e^{-j2\pi u t} \mathrm{d}t = \int f(t) e^{j2\pi u t} \mathrm{d}t = F(-u). \] -
\(\hat{F}(t) = \int F(u) e^{j2\pi t u} \mathrm{d}u = (F(-u))^{\check{}}(t) = f(-t)\).
-
scaling:
\[(f(at))^{\hat{}}(u) = \int_{-\infty}^{+\infty} f(at) e^{-j2\pi ut} \mathrm{d}t = \frac{1}{|a|}\int_{-\infty}^{+\infty} f(z) e^{-j2\pi \frac{u}{a}z} dz = \frac{1}{|a|} F(\frac{u}{a}). \] -
导函数:
\[\begin{array}{ll} f‘(t) &= \frac{\mathrm{d}}{\mathrm{d}t} \int_{-\infty}^{+\infty} F(u) e^{j2\pi t u} \mathrm{d}u \&= \int_{-\infty}^{+\infty} F(u) \frac{\mathrm{d}}{\mathrm{d}t} e^{j2\pi t u} \mathrm{d}u \&= \int_{-\infty}^{+\infty} F(u) (j2\pi u) e^{j2\pi t u} \mathrm{d}u \&= (j2\pi u F(u))^{\check{}}. \end{array} \] -
同上
-
这个性质说明了, 对原图像加以旋转, 等价地在频域上加以同样的旋转.
\[\begin{array}{ll} G(\mathbf{u}) &=\int f(R\mathbf{t}) e^{-j2 \pi \mathbf{u}^T \mathbf{t}} \mathrm{d}\mathbf{t} \ &=\int f(\mathbf{x}) e^{-j2 \pi (R\mathbf{u})^T \mathbf{x}} |R^{-1}|\mathrm{d}\mathbf{x} \ &=\int f(\mathbf{x}) e^{-j2 \pi (R\mathbf{u})^T \mathbf{x}} \mathrm{d}\mathbf{x} \ &=F(R\mathbf{u}) \end{array} \]
对称性
主要指的:
-
奇函数
\[f(x) = -f(-x). \] -
偶函数
\[f(x) = f(-x). \] -
共轭对称
\[f^*(x) = f(-x). \]
考查\(f(t)=r(t) + j i(t)\)与\(F(u) = R(u) + j I(u)\)之间的关系:
\(\hat{ }\) | \(\Leftrightarrow\) | \(\check{ }\) | |
---|---|---|---|
1 | \(f(t) = r(t)\) | \(\Leftrightarrow\) | \(F^*(u) = F(-u)\) |
2 | \(f(t)=r(t)\) | \(\Leftrightarrow\) | \(R(u)=R(-u), I(u)=-I(-u)\) |
3 | \(f(t) = ji(t)\) | \(\Leftrightarrow\) | \(F^*(-u) = -F(u)\) |
4 | \(f(t) = ji(t)\) | \(\Leftrightarrow\) | \(R(u)=-R(-u), I(u)=I(-u)\) |
\(\hat{}\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(\check{}\) | |
---|---|---|---|
5 | \(f(-t)\in \mathbb{R}\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F^*(u) \in \mathbb{C}\) |
6 | \(f(-t) \in \mathbb{C}\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(-u) \in \mathbb{C}\) |
7 | \(f^*(t) \in \mathbb{C}\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F^*(-u) \in \mathbb{C}\) |
8 | \(f(t) \in \mathbb{R}\), 且\(f(t) = f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) \in \mathbb{R}\), 且满足\(F(u)=F(-u)\) |
9 | \(f(t) \in \mathbb{R}\), 且\(f(t) = -f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) = jI(u) \in \mathbb{C}\), 且\(F(u)=-F(-u)\) |
10 | \(f(t) = ji(t) \in \mathbb{C}\), 且\(f(t) = f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) = jI(u) \in \mathbb{C}\), 且\(F(u)=F(-u)\) |
11 | \(f(t)=ji(t) \in \mathbb{C}\), 且\(f(t)=-f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) \in \mathbb{R}\), 且满足\(F(u)=-F(-u)\) |
12 | \(f(t) \in \mathbb{C}\), 且\(f(t) = f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) \in \mathbb{C}\), 且满足\(F(u) = F(-u)\) |
13 | \(f(t) \in \mathbb{C}\), 且\(f(t) = -f(-t)\) | \(\mathop{\Leftrightarrow} \limits^{\mathcal{F}}\) | \(F(u) \in \mathbb{C}\), 且满足\(F(u) = -F(-u)\) |
-
real ->(\(\Leftarrow\)采用反证法即可)
\[\begin{array}{ll} F^*(u) &=[\int f(t) e^{-j2\pi ut} \mathrm{d}t]^* \&=\int f^*(t) e^{j2\pi ut} \mathrm{d}t \&=\int f(t) e^{-j2\pi (-u)t} \mathrm{d}t \rightarrow f*(t) = r^*(t) = r(t)\&=F(-u). \end{array} \] -
由1易证.
-
imaginary ->
\[\begin{array}{ll} F^*(-u) &=[\int f(t) e^{j2\pi ut} \mathrm{d}t]^* \&=\int f^*(t) e^{-j2\pi ut} \mathrm{d}t \&=\int -f(t) e^{-j2\pi ut} \mathrm{d}t \rightarrow f^*(t) = -ji(t)=-f(t) \&=-F(u). \end{array} \] -
由3易证.
-
由性质6以及上述的对称性3可知\((f(-t))^{\hat{}}= F(-u) = F^*(u)\).
-
由性质6可知\((f(-t))^{\hat{}} = F(-u)\).
-
\[\int f^*(t) e^{-j2\pi ut} \mathrm{d}t = [\int f(t) e^{j2\pi ut} \mathrm{d}t]^* = F^*(-u). \]
-
\[F(u) = (f(t))^{\hat{}} = (f(-t))^{\hat{}} = F(-u) = F^*(u). \]
-
\[F(u) = (f(t))^{\hat{}} = -(f(-t))^{\hat{}} = -F(-u) = -F^*(u). \]
-
\[F(u) = (f(t))^{\hat{}} = (f(-t))^{\hat{}} = F(-u) = -F^*(u). \]
-
\[F(u) = (f(t))^{\hat{}} = -(f(-t))^{\hat{}} = -F(-u) = F^*(u). \]
-
\[F(u) = (f(t))^{\hat{}} = (f(-t))^{\hat{}} = F(-u). \]
-
\[F(u) = (f(t))^{\hat{}} = -(f(-t))^{\hat{}} = -F(-u). \]
卷积
这里特别说明离散卷积的一个重要性质:
注意到
则
定义
则有
FFT
考虑离散傅里叶变换:
每次计算包含\(N\)个乘法, 故傅里叶变换的计算量是\(N^2\)级别的.
下面假设\(N = P * Q, P, Q \in \mathbb{N}^+\), 则
注意到:
此时, \(m, n\)与唯一的\((u,v), (s, t)\)匹配, 则傅里叶变换可以表示为:
令
显然总共需要\(QN\)次乘法, 而
总共有\(PN\)次乘法, 故总共有\((P+Q) N\)次乘法运算.
由于每个\(F^t\)都是一个独立的傅里叶变换过程, 故倘若\(Q\)能够进一步分解, 计算量可以进一步降低.
甚至, 若假设\(N = P^J\), 则可以证明最后的计算量可以分解为
特别的, 常常\(N=2^J\), 则计算量是\(N\log_2 N\)量级的.
注: 卷积运算\([f\star g]_n, n=0,\cdots, N-1\), 计算量也是\(N^2\)级别的, 但是通过FFT, 应当是\((PN\log_P + 1)N\)?乘法次数, 也是可以降低计算量的.
逆傅里叶变换实际上就是
虽然下面的代码我并没有采取这种策略.
from typing import Iterable, Union
import numpy as np
def factorization(N: int):
for P in range(2, N + 1):
if N % P is 0:
return P
def dft(arr: Iterable, m: int):
N = len(arr)
basis = np.arange(N) * m * 2 * np.pi * 1j * -1
basis = np.exp(basis / N)
return arr @ basis
def idft(arr: Iterable, m: int):
N = len(arr)
basis = np.arange(N) * m * 2 * np.pi * 1j
basis = np.exp(basis / N) / N
return arr @ basis
def basis_dft(N: int):
basis = np.outer(np.arange(N), np.arange(N))
basis = basis * 2 * np.pi * 1j * -1
return np.exp(basis / N)
def basis_idft(N: int):
basis = np.outer(np.arange(N), np.arange(N))
basis = basis * 2 * np.pi * 1j
return np.exp(basis / N) / N
def fft(arr: Iterable) -> np.ndarray:
N = len(arr)
P = factorization(N)
if P is N:
return arr @ basis_dft(N)
Q = N // P
Fvt = np.array([fft(arr[t::P]) for t in range(P)]).T # Q x P
dummy = np.outer(np.arange(Q), np.arange(P))
dummy = np.exp((dummy * 2 * np.pi * 1j * -1) / N)
Fvt_ext = Fvt * dummy
return (Fvt_ext @ basis_dft(P)).T.flatten()
def ifft(arr: Iterable) -> np.ndarray:
N = len(arr)
P = factorization(N)
if P is N:
return arr @ basis_idft(N)
Q = N // P
Fvt = np.array([ifft(arr[t::P]) for t in range(P)]).T # Q x P
dummy = np.outer(np.arange(Q), np.arange(P))
dummy = np.exp((dummy * 2 * np.pi * 1j) / N)
Fvt_ext = Fvt * dummy
return (Fvt_ext @ basis_idft(P)).T.flatten()