离散余弦变换 DCT
先说结论,DCT 变换就是输入信号为实偶函数的 DFT 变换。
对于一个长度为 N 的实数离散信号:
x
[
n
]
=
{
x
[
0
]
,
x
[
1
]
,
.
.
.
,
x
[
N
−
1
]
}
x[n]=\{x[0],x[1],...,x[N-1]\}
x[n]={x[0],x[1],...,x[N−1]}。其 DFT 可以表示为:
X
[
k
]
=
∑
n
=
0
N
−
1
x
[
n
]
e
−
i
n
2
π
N
k
(1)
X[k] =\sum_{n=0}^{N-1} x[n] e^{-in\frac{2\pi}{N}k} \tag{1}
X[k]=n=0∑N−1x[n]e−inN2πk(1)
先将其扩大为原来的 2 倍,则新的信号
x
′
[
n
]
x'[n]
x′[n] 为:
x
′
[
n
]
=
x
[
n
]
,
w
h
e
r
e
0
≤
n
≤
N
−
1
x
′
[
n
]
=
x
[
−
n
−
1
]
,
w
h
e
r
e
−
N
≤
n
≤
−
1
x'[n] = x[n]\ ,\ where \ 0 \leq n \leq N-1 \\ x'[n] = x[-n - 1]\ ,\ where \ -N \leq n \leq -1 \\
x′[n]=x[n] , where 0≤n≤N−1x′[n]=x[−n−1] , where −N≤n≤−1
由于其并不关于
n
=
0
n=0
n=0 对称,因此,需要将其右移
1
2
\frac{1}{2}
21 个单位。其对应的 DFT 改变成:
X
′
[
k
]
=
∑
n
=
−
N
+
1
2
N
−
1
2
x
′
[
n
−
1
2
]
e
−
i
n
2
π
2
N
k
X'[k] =\sum_{n=-N+\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] e^{-in\frac{2\pi}{2N}k}
X′[k]=n=−N+21∑N−21x′[n−21]e−in2N2πk
进一步:
X
′
[
k
]
=
∑
n
=
−
N
+
1
2
N
−
1
2
x
′
[
n
−
1
2
]
cos
(
n
2
π
2
N
k
)
−
∑
n
=
−
N
+
1
2
N
−
1
2
x
′
[
n
−
1
2
]
sin
(
n
2
π
2
N
k
)
X'[k] =\sum_{n=-N+\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] \cos(n\frac{2\pi}{2N}k) - \sum_{n=-N+\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] \sin(n\frac{2\pi}{2N}k)
X′[k]=n=−N+21∑N−21x′[n−21]cos(n2N2πk)−n=−N+21∑N−21x′[n−21]sin(n2N2πk)
因为
x
′
[
n
−
1
2
]
x'[n - \frac{1}{2}]
x′[n−21] 是偶函数,
sin
(
n
2
π
2
N
k
)
\sin(n\frac{2\pi}{2N}k)
sin(n2N2πk) 是奇函数,
∑
n
=
−
N
+
1
2
N
−
1
2
x
′
[
n
−
1
2
]
sin
(
n
2
π
2
N
k
)
=
0
\sum_{n=-N+\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] \sin(n\frac{2\pi}{2N}k) = 0
∑n=−N+21N−21x′[n−21]sin(n2N2πk)=0,则:
X
′
[
k
]
=
∑
n
=
−
N
+
1
2
N
−
1
2
x
′
[
n
−
1
2
]
cos
(
n
2
π
2
N
k
)
=
2
∑
n
=
1
2
N
−
1
2
x
′
[
n
−
1
2
]
cos
(
n
2
π
2
N
k
)
X'[k] =\sum_{n=-N+\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] \cos(n\frac{2\pi}{2N}k) \\ = 2\sum_{n=\frac{1}{2}}^{N-\frac{1}{2}} x'[n - \frac{1}{2}] \cos(n\frac{2\pi}{2N}k)
X′[k]=n=−N+21∑N−21x′[n−21]cos(n2N2πk)=2n=21∑N−21x′[n−21]cos(n2N2πk)
令
m
=
n
−
1
2
m = n - \frac{1}{2}
m=n−21,最终:
X
′
[
k
]
=
2
∑
m
=
0
N
−
1
x
′
[
m
]
cos
(
(
m
+
1
2
)
π
k
N
)
X'[k] = 2\sum_{m=0}^{N-1} x'[m] \cos(\frac{(m+\frac{1}{2})\pi k}{N})
X′[k]=2m=0∑N−1x′[m]cos(N(m+21)πk)
在实际的工程中,为了在 DCT 变换变成二维矩阵运算的形式时,将该矩阵正交化以便于进一步的计算,那么,可以乘以一个系数
1
2
N
\sqrt{\frac{1}{2N}}
2N1 (
k
=
0
k=0
k=0 时除外):
X
′
[
k
]
=
2
N
∑
m
=
0
N
−
1
x
′
[
m
]
cos
(
(
m
+
1
2
)
π
k
N
)
X'[k] = \sqrt{\frac{2}{N}}\sum_{m=0}^{N-1} x'[m] \cos(\frac{(m+\frac{1}{2})\pi k}{N})
X′[k]=N2m=0∑N−1x′[m]cos(N(m+21)πk)