35
預預預預 (Predictive Coding) 4

預測編碼 (Predictive Coding)

  • Upload
    chas

  • View
    145

  • Download
    0

Embed Size (px)

DESCRIPTION

預測編碼 (Predictive Coding). 4. 簡介. Delta modulation (DM) Difference pulse code modulation (DPCM). Delta Modulation. Delta Modulation. Delta Modulation. Adaptive Delta Modulation. Adaptive Delta Modulation. DPCM. DPCM. 定義 為差異序列 (difference sequence) 的變異量 (variance) (4.1) - PowerPoint PPT Presentation

Citation preview

Page 1: 預測編碼 (Predictive Coding)

預測編碼(Predictive Coding)

4

Page 2: 預測編碼 (Predictive Coding)

簡介 Delta modulation (DM)

Difference pulse code modulation (DPCM)

Page 3: 預測編碼 (Predictive Coding)

Delta Modulation

0負差值 正差值

輸出

輸入

Page 4: 預測編碼 (Predictive Coding)

Delta Modulation

輸入

單位時間延遲

輸出

預測值

積分器

+_

+

+

Page 5: 預測編碼 (Predictive Coding)

Delta Modulation

原波形

粒狀雜訊之範圍

重建波形

斜率超負載之範圍

送出之脈衝

Page 6: 預測編碼 (Predictive Coding)

Adaptive Delta Modulation

1

1

單位時間延遲

+_

適應性函數

1KS1KE

+

+

kX 1kX

存於其中

,E , mink k

1 k

Page 7: 預測編碼 (Predictive Coding)

Adaptive Delta Modulation

1 1

1 min

1

min 1 min

1 1

1

2

k k k

k k k k

k

k k

k k k

E sign of S X

E E if

E if

X X

Page 8: 預測編碼 (Predictive Coding)

DPCM

Q

P

+_

+

+

xn dn dn^

pn

xn^

pn

Ppn

dn^

xn^+

+

Encoder

Decoder

Page 9: 預測編碼 (Predictive Coding)

DPCM

定義 為差異序列 (difference sequence)的變異量 (variance)

(4.1)假設量化階極小而能以 取代

(4.2)

2d

22d n nσ E x p

ˆnx nx

1 2 0

1 2 0

ˆ ˆ ˆ( , , , )

( , , , )n n n

n n

p f x x x

f x x x

Page 10: 預測編碼 (Predictive Coding)

DPCM

假設預測函數是線性方程式,則

(4.3) N 的值就是預測函數的階數 (order)

由 (4.1) 及 (4.3) ,可得

(4.4)

1

ˆN

n i n ii

p a x

2

2

1

N

d n i n ii

σ E x a x

Page 11: 預測編碼 (Predictive Coding)

DPCM

設計預測器就是要找出使 最小的 。

對每個 ai取 的偏微分,並令為零。

(4.5)

2d { }ia

2d

2

111

2

212

2

1

2 0

2 0

2 0

Nd

n i n i ni

Nd

n i n i ni

Nd

n i n i n NiN

dE x a x x

da

dE x a x x

da

dE x a x x

da

Page 12: 預測編碼 (Predictive Coding)

DPCM

(7.5) 可改寫為:

(4.6)

1

1

1

( 1) (1)

( 2) (2)

( ) ( )

N

i xx xxi

N

i xx xxi

N

i xx xxi

a R i R

a R i R

a R i N R N

Page 13: 預測編碼 (Predictive Coding)

DPCM

Rxx(k) 就是 xn的自相關函數 (autocorrelation functio

n)

(4.7)

上述公式可用矩陣形式表示RA = P (4.

8)

其中,

( ) [ ]xx n n kR k E x x

Page 14: 預測編碼 (Predictive Coding)

DPCM

(4.9)

(4.10)

1

2

3

(0) (1) (2) ( 1)

(1) (0) (1) ( 2)

(2) (1) (0) ( 3)

( 1) ( 2) ( 3) (0)

xx xx xx xx

xx xx xx xx

xx xx xx xx

xx xx xx xx

N

R R R R N

R R R R N

R R R R R N

R N R N R N R

a

a

A a

a

Page 15: 預測編碼 (Predictive Coding)

DPCM

(4.11)

若知道自相關係數 {Rxx(k)} ,就能找出預測器係數。 A=R-1P (4.12)

(1)

(2)

(3)

( )

xx

xx

xx

xx

R

R

P R

R N

Page 16: 預測編碼 (Predictive Coding)

DPCM

範例 若右圖為影像之一部分 B

XA

DC ..........

..........

..........

.......... ...ˆ 0.97A

ˆ 0.5A 0.5C

ˆ 0.9A 0.81B 0.9C

ˆ 0.75A 0.5B 0.75C

ˆ A B C

x

x

x

x

x

Page 17: 預測編碼 (Predictive Coding)

DPCM

量化器的最佳化量化器的設計可依據統計結果或是人類視覺系統 (VHS, human visual system)

然而人類視覺系統不易描繪。

Page 18: 預測編碼 (Predictive Coding)

DPCM

,其中 e 是實數或整數而 e*

是離散變數, 。

定義 ,使得若 e (di, di+1] 則 e* rj。

只要針對已知的 p(e) 最佳化 {di} 及 {ri} ,就可以完成量化器的最佳化。

*:Q e e 0 1 1*

ie r ,i , ,.....,N

0 1i d ,i , ,....,N

Page 19: 預測編碼 (Predictive Coding)

DPCM

使 最小化,可得到

(4.13)

(4.14)

11

2

0

i

i

N d

idi

D e r p e de

1 1

1

2i i

i i

i ii

d d

i d d

r rd

r ep e p e de

Page 20: 預測編碼 (Predictive Coding)

DPCM

(4.13) 與 (4.14) 可用數值方法求解step1: 以亂數設定 di初始值;step2: 使用 di及 (4.14) 計算 ri;step3: 使用 ri及 (4.13) 計算 di;step4: 回到 step2 直到 di及 ri收斂為止。

多數狀況下, di 及 ri會在幾次迭代之內收斂。

Page 21: 預測編碼 (Predictive Coding)

DPCM

例如:給定 N = 8 及 p(e) : Laplacian 分布p(e)

e0

Page 22: 預測編碼 (Predictive Coding)

DPCMi Probability Huffman code0 (-255, -16] -20 0.025 1111111 (-16, -8] -11 0.047 111102 (-8, -4] -6 0.145 1103 (-4, 0] -2 0.278 004 (0, 4] 2 0.283 105 (4, 8] 6 0.151 016 (8, 16] 11 0.049 11107 (16, 255] 20 0.022 111110

8-level Lloyd-max quantizer for Lena

Page 23: 預測編碼 (Predictive Coding)

A( 適應性 )DPCM

DPCM 及 DM 的問題 粒狀雜訊 (granular noise)

斜率超載 (slope overload)

適應性預測器可改善 類似 ADM 的設計方式 針對邊緣部份可改善影像品質達 4dB

Page 24: 預測編碼 (Predictive Coding)

ADPCM

適應性量化器 (adaptive quantizer)

正規化 (normalize) 誤差訊號並使用 來調整 及 。

或正規化 並使用固定的 及 。交換量化器 (switched quantizer)

使用 2 階或 3 階馬可夫程序。 不同的狀態對應不同的量化器

e idir

e id ir

Page 25: 預測編碼 (Predictive Coding)

ADPCM量化器一

預測器一

+_ +

+

編碼器一

誤差一

+_

量化器二

預測器二

+_ +

+

編碼器二

誤差二

+_

量化器三

預測器三

+_ +

+

編碼器三

誤差三

+_

量化器四

預測器四

+_ +

+

編碼器四

誤差四

+_

nx

編碼器輸出

額外資訊

Page 26: 預測編碼 (Predictive Coding)

實驗結果 LENA BOOTS

TechniqueBit rate

bits/pixelRMSE(0-255)

SNR(dB)

RMSE(0-255)

SNR(dB)

1-D DPCM 1.00 18.67 22.71 22.79 20.981-D DPCM 2.00 9.44 28.63 10.96 27.331-D DPCM 3.00 5.11 33.96 5.33 33.62-D DPCM 1.00 14.58 27.74 15.91 24.12-D DPCM 2.00 6.93 31.32 7.7 30.42-D DPCM 3.00 3.71 36.74 4.01 36.07

1-D ADPCM 1.20 10.91 27.37 14.12 25.131-D ADPCM 2.20 4.37 35.32 5.97 32.611-D ADPCM 3.20 2.16 41.44 3.16 38.142-D ADPCM 1.20 7.84 30.24 10.2 27.962-D ADPCM 2.20 2.87 38.97 4.75 34.62-D ADPCM 3.20 1.37 45.4 2.56 39.97

1 predictor

ˆ 0.97

D

x A

2 predictor

ˆ 0.75A 0.50B 0.75C

D

x

Page 27: 預測編碼 (Predictive Coding)

實驗結果 DPCM, 1.0 bpp

Page 28: 預測編碼 (Predictive Coding)

實驗結果 DPCM, 2.0 bpp

Page 29: 預測編碼 (Predictive Coding)

實驗結果 DPCM, 3.0 bpp

Page 30: 預測編碼 (Predictive Coding)

實驗結果 DPCM, 2.0 bpp

Page 31: 預測編碼 (Predictive Coding)

實驗結果 ADPCM, 1.2 bpp

Page 32: 預測編碼 (Predictive Coding)

實驗結果 ADPCM, 2.2 bpp

Page 33: 預測編碼 (Predictive Coding)

實驗結果 ADPCM, 3.2 bpp

Page 34: 預測編碼 (Predictive Coding)

結論預測編碼與無失真壓縮

JPEG

Prediction

0 No

1 A

2 B

3 C

4 A+B-C

5 A-(B-C)/2

6 B-(A-C)/2

7 (A+B)/2

B

XA

DC ..........

..........

..........

.......... ...

Page 35: 預測編碼 (Predictive Coding)

結論預測編碼大多做為後處理器使用

JPEG :轉換後的 DC 係數之編碼 MPEG-4 :紋理編碼中,轉換後之 DC 與 AC 係數之編碼

Lena Huffman Arithmetic AHuff AArith Winzip JPEG-LS

No

DPCM 1.05 1.05 1.06 1.43 1.12

D P C M 1.59 1.59 1.62 1.56 1.50 1.74