# 一维离散余弦变换（DCT)及其反变换（IDCT）公式的一种推导

## 前言

取一维离散Fourier变换与反变换的公式为
F ( u ) = c ∑ n = 0 N − 1 f ( n ) e − j 2 π u n N ,   u = 0 , 1 , ⋯   , N − 1 f ( n ) = d ∑ u = 0 N − 1 F ( u ) e j 2 π u n N ,   n = 0 , 1 , ⋯   , N − 1 c d = 1 N \begin{matrix} F\left( u \right)=c\sum\limits_{n=0}^{N-1}{f\left( n \right){ {e}^{-j\frac{2\pi un}{N}}}},\text{ }u=0,1,\cdots ,N-1 \\ f\left( n \right)=d\sum\limits_{u=0}^{N-1}{F\left( u \right){ {e}^{j\frac{2\pi un}{N}}}},\text{ }n=0,1,\cdots ,N-1 \\ cd=\frac{1}{N} \\ \end{matrix}

## DCT公式初步推导

基于公式
F ( u ) = c ∑ n = 0 N − 1 f ( n ) e − j 2 π u n N ,   u = 0 , 1 , ⋯   , N − 1 F\left( u \right)=c\sum\limits_{n=0}^{N-1}{f\left( n \right){ {e}^{-j\frac{2\pi un}{N}}}},\text{ }u=0,1,\cdots ,N-1

### 一般形式

令 f ( n ) = g ( n ) e − j p π u q N ,   p , q ≠ 0 f\left( n \right)=g\left( n \right){ {e}^{-j\frac{p\pi u}{qN}}},\text{ }p,q\ne 0 其中 g ( n ) g\left( n \right) 通过个数为 t N ( t ∈ Z ≥ 1 ) tN\left( t\in { {\mathbb{Z}}_{\ge 1}} \right) 的一个空间域（时域）实数采样序列：
g ( 0 ) , g ( 1 ) , ⋯   , g ( N − 1 ) ,   g ( N ) , ⋯   , g ( t N − 1 ) ,   ∀ n ,   g ( n ) ∈ R g\left( 0 \right),g\left( 1 \right),\cdots ,g\left( N-1 \right),\text{ }g\left( N \right),\cdots ,g\left( tN-1 \right),\text{ }\forall n,\text{ }g\left( n \right)\in \mathbb{R}

F ( u ) = c ∑ n = 0 t N − 1 [ ( g ( n ) e − j p π u q N ) ⋅ e − j 2 π u n t N ] = c ∑ n = 0 t N − 1 [ g ( n ) ⋅ ( e − j p π u q N ⋅ e − j 2 π u n t N ) ] = c ∑ n = 0 t N − 1 g ( n ) e − j ( p t + 2 n q ) u π q t N = c ∑ n = 0 t N − 1 g ( n ) ( cos ⁡ ( p t + 2 n q ) u π q t N − i sin ⁡ ( p t + 2 n q ) u π q t N ) = c ∑ n = 0 N − 1 g ( n ) ( cos ⁡ ( p t + 2 n q ) u π q t N − i sin ⁡ ( p t + 2 n q ) u π q t N ) \begin{aligned} & F\left( u \right)=c\sum\limits_{n=0}^{tN-1}{\left[ \left( g\left( n \right){ {e}^{-j\frac{p\pi u}{qN}}} \right)\centerdot { {e}^{-j\frac{2\pi un}{tN}}} \right]} \\ & =c\sum\limits_{n=0}^{tN-1}{\left[ g\left( n \right)\centerdot \left( { {e}^{-j\frac{p\pi u}{qN}}}\centerdot { {e}^{-j\frac{2\pi un}{tN}}} \right) \right]} \\ & =c\sum\limits_{n=0}^{tN-1}{g\left( n \right){ {e}^{-j\frac{\left( pt+2nq \right)u\pi }{qtN}}}} \\ & =c\sum\limits_{n=0}^{tN-1}{g\left( n \right)\left( \cos \frac{\left( pt+2nq \right)u\pi }{qtN}-i\sin \frac{\left( pt+2nq \right)u\pi }{qtN} \right)} \\ & =c\sum\limits_{n=0}^{N-1}{g\left( n \right)\left( \cos \frac{\left( pt+2nq \right)u\pi }{qtN}-i\sin \frac{\left( pt+2nq \right)u\pi }{qtN} \right)} \\ \end{aligned}
对 F ( u ) F\left( u \right) 取实部，得到计算 C ( u ) C\left( u \right) 的DCT公式
C ( u ) = Re ⁡ ( F ( u ) ) = c ∑ n = 0 N − 1 g ( n ) cos ⁡ ( p t + 2 n q ) u π q t N ,   u = 0 , 1 , ⋯   , N − 1 C\left( u \right)=\operatorname{Re}\left( F\left( u \right) \right)=c\sum\limits_{n=0}^{N-1}{g\left( n \right)\cos \frac{\left( pt+2nq \right)u\pi }{qtN}},\text{ }u=0,1,\cdots ,N-1

### 标准形式

在DCT公式一般形式中，令 p = 1 ,   q = t = 2 p=1,\text{ }q=t=2 则有
C ( u ) = c ∑ n = 0 N − 1 g ( n ) cos ⁡ ( 2 + 2 × n × 2 ) u π 4 N = c ∑ n = 0 N − 1 g ( n ) cos ⁡ ( 2 n + 1 ) u π 2 N ,   u = 0 , 1 , ⋯   , N − 1 \begin{aligned} & C\left( u \right)=c\sum\limits_{n=0}^{N-1}{g\left( n \right)\cos \frac{\left( 2+2\times n\times 2 \right)u\pi }{4N}} \\ & =c\sum\limits_{n=0}^{N-1}{g\left( n \right)\cos \frac{\left( 2n+1 \right)u\pi }{2N}},\text{ }u=0,1,\cdots ,N-1 \\ \end{aligned}

## IDCT公式初步推导

基于公式
f ( n ) = d ∑ u = 0 N − 1 F ( u ) e j 2 π n u N ,   n = 0 , 1 , ⋯   , N − 1 f\left( n \right)=d\sum\limits_{u=0}^{N-1}{F\left( u \right){ {e}^{j\frac{2\pi nu}{N}}}},\text{ }n=0,1,\cdots ,N-1

### 一般形式

令
F ( u ) = C ( u ) e j p π u q N F\left( u \right)=C\left( u \right){ {e}^{j\frac{p\pi u}{qN}}}

C ( 0 ) , C ( 1 ) , ⋯   , C ( N − 1 ) , C ( N ) , ⋯   , C ( t N − 1 ) ,   ∀ u ,   C ( u ) ∈ R C\left( 0 \right),C\left( 1 \right),\cdots ,C\left( N-1 \right),C\left( N \right),\cdots ,C\left( tN-1 \right),\text{ }\forall u,\text{ }C\left( u \right)\in \mathbb{R}

• 9
点赞
• 43
收藏
觉得还不错? 一键收藏
• 打赏
• 1
评论
12-11
10-28 3325
12-23 7609
08-31 8916
10-18 5166
12-01 1154
09-08 2789
10-24 1万+
10-24 3579
11-17 2570
10-01 2524

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

¥1 ¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。