No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless...

25
Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 1 Predictive Coding Lossless predictive coding Optimum predictors JPEG-LS lossless compression standard Lossy predictive coding: DPCM Rate distortion performance of DPCM

Transcript of No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless...

Page 1: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 1

Predictive Coding

Lossless predictive coding

Optimum predictors

JPEG-LS lossless compression standard

Lossy predictive coding: DPCM

Rate distortion performance of DPCM

Page 2: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 2

Lossless Predictive Coding

Prediction mp [n] is calculated for x[n] from previous samples

e[n] is prediction error, with greatly reduced statistical dependencies

between adjacent samples

Entropy coder may assume i.i.d. prediction error e[n]

Receiver can reconstruct x[n] without loss for amplitude-discrete

signals

Much simpler than context-adaptive coder

[ ]x n

Predictor

Entropy

Coder

Entropy

Decoder

Predictor

+

+

+

-

Encoder Decoder

[ ]e n [ ]e n [ ]x n

pm n

nxΝ

, ,px em

pm n

Page 3: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 3

Lossless Predictive Coding

Prediction mp [n] is calculated for x[n] from previous samples

e[n] is prediction error, with greatly reduced statistical dependencies

between adjacent samples

Entropy coder may assume i.i.d. prediction error e[n]

Receiver can reconstruct x[n] without loss for amplitude-discrete

signals

Much simpler than context-adaptive coder

[ ]x n

Predictor

Entropy

Coder

Entropy

Decoder

Predictor

+

+

+

-

Encoder Decoder

[ ]e n [ ]e n [ ]x n

pm n

nxΝ

, ,px em

pm n

Integers!

Page 4: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 4

original

0.95

0 0 0

0

0 0.95 0

0.5

0 0.5 0

Prediction example: test pattern

Page 5: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 5

Prediction example: Cameraman

original

0.95

0 0 0

0

0 0.95 0

0.5

0 0.5 0

Page 6: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 6

0 50 100 150 200 250 0

500

1000

1500

2000

2500

3000

Image signal Prediction error

-50 0 50 0

0.5

1

1.5

2 x 10

4

Histograms: Cameraman

0.5

0 0.5 0

Page 7: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 7

Entropy and variance of the prediction error

Approximation of the entropy of the prediction error E

Shape constant

With linear prediction of image signals the prediction error

PDF is typically Laplacian.

Minimization of prediction error variance or prediction error

entropy typically lead to very similar results.

2( ) log for Epdf EH E c

constant that depends on

the shape of the underlying PDF standard deviation of E

quantization step size

Gaussian PDF: Laplacian PDF: 2.047 bitpdfc 1.943 bitpdfc

Page 8: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 8

-100 -50 0 50 1000

0.02

0.04

0.06

0.08

0.1

0.12

Optimum linear predictors for the luminance signal Y

Predictor 0( )H X

[bit] a1 a2

a3

MSE ( )H E

[bit] Criterion

0.595 -0.434 0.831 33.810 4.301 minimum variance 7.23

0.464 -0.264 0.799 35.075 4.2813 minimum entropy

2x line of pixels

above

current line of

pixels

E H(E) log2 2eE log2 argminE argminH(E)

Image: ‘Lena’, 512 x 512 pixels, 8 bpp Δ =1, 28 levels (-128..127)

)(efE approx. Laplacian

3x

1x0x

Page 9: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 9

Optimum linear predictors for the luminance signal Y

Predictor 0( )H X

[bit] a1 a2

a3

MSE ( )H E

[bit] Criterion

5/8 -1/2 7/8 34.161 4.318 minimum variance 7.23

1/2 -1/4 3/4 35.395 4.285 minimum entropy

Image: ‘Lena’, 512 x 512 pixels, 8 bpp

Constraint: 3 bit word length of the prediction coefficients, +1 bit for sign

Δ =1, 28 levels (-128..127)

-100 -50 0 50 1000

0.02

0.04

0.06

0.08

0.1

0.12

line of pixels

above

current line of

pixels

)(efE approx. Laplacian

2x3x

1x0x

Page 10: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 10

JPEG-LS lossless compression standard

Standards ISO/IEC 14495-1 and ITU-T T.87 [1999]

Not to be confused with lossless mode of original JPEG

Based on LOCO-I (Low Complexity Compression of

Images) [Weinberger, Seroussi, Sapiro, 1996]

Predictive coding with nonlinear predictor

Context-adaptive Golomb coding of prediction error

365 different coding contexts, based on pixel differences in

the causal neighborhood

Switches to 1-d run-length coding for one context

Run-lengths encoded by Golomb code

“Near-lossless” mode extension

Page 11: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 11

JPEG-LS blockdiagram

[Weinberger, Seroussi, Sapiro, 2000]

Page 12: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 12

JPEG-LS nonlinear predictor

S2 S3 S4

S1 S0

1 3 2 1 2 3

1 3 2 1 2 3

1 2 3

min , if S max , ,

max , if S min , ,

else

p

S S S S S

S S S S S

S S S

m

Page 13: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 13

JPEG-LS nonlinear predictor

S2 S3 S4

S1 S0

1 3 2 1 2 3

1 3 2 1 2 3

1 2 3

min , if S max , ,

max , if S min , ,

else

p

S S S S S

S S S S S

S S S

m

100

25

100

Page 14: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 14

JPEG-LS nonlinear predictor

S2 S3 S4

S1 S0

1 3 2 1 2 3

1 3 2 1 2 3

1 2 3

min , if S max , ,

max , if S min , ,

else

p

S S S S S

S S S S S

S S S

m

23

29

100

Page 15: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 15

JPEG-LS context labeling

Quantize each Δi to 1 out of 9 different indices:

93=729 distinct contexts, default thresholds 3,7,21

Further reduce to 365 contexts by exploiting sign symmetries

For Δ1= Δ2= Δ3=0, switch to run-length coding

S2 S3 S4

S1 S0

12

3

Page 16: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 16

Lossy Predictive Coding:

Differential Pulse Code Modulation (DPCM)

quantizerentropy coder

predictor

+

+

-

+ e'

s'

einput channel

s

+

+

predictor

entropy decoder

s' e'output

s

channel

s

coder

decoder

Reconstruction error = quantization error

'x x e e q

[ ]x n [ ]e n '[ ]e n

'[ ]x n

'[ ]e n

pm

'[ ]x n

pm n

pm n

Page 17: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 17

quantizerentropy coder

predictor

+

+

-

+ e'

s'

einput channel

s

+

+

predictor

entropy decoder

s' e'output

s

channel

s

pm

'[ ]x n'[ ]e n

Quantization error feedback in the DPCM coder

For a linear predictor, the DPCM coder is equivalent to:

Linear DPCM decoder

quantizers e+

- -

s (s) s (q)

q (e)

-

+

e e'~

predictor predictor

[ ]x n [ ]e n '[ ]e n

[ ]q n

Image filtered by

1 ( , )x yP

Quantization error filtered by

1 ( , )x yP

1 1 ( , )x yP

Page 18: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 18

Example of intraframe DPCM coding

prediction error coding

1 bit/pixel 2 bit/pixel 3 bit/pixel

4 bit/pixel original

slope overload

edge busyness

granular noise Linear predictor:

Lloyd-Max quantizers

Fixed-length coding

Page 19: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 19

Signal distortions due to intraframe DPCM coding

Granular noise: random

noise in flat areas of the

picture

Edge busyness: jittery

appearance of edges

(for video)

Slope overload: blur of

high-contrast edges,

Moire patterns in periodic

structures.

[Netravali + Haskell]

Page 20: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 20

K=511 K=15 K=3

H(e’)=H(e)=4.79 bpp H(e’)=1.98 bpp H(e’)=0.88 bpp

K ... number of reconstruction levels,

H(e’) ... entropy of quantized prediction error [J. R. Ohm]

DPCM with entropy-constrained quantization

Page 21: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 21

Recall from Chapter “Quantization”

High-rate performance of scalar quantizers

High-rate distortion-rate function

Scaling factor

2 2 22 R

Xd R

2

2

Shannon LowBd Lloyd-Max Entropy-coded

6Uniform 0.703 1 1

e

9Laplacian 0.865 4.5 1.232

2 6

3Gaussian 1 2.721 1.423

2 6

e e

e

Page 22: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 22

Predictive coding gain

High-rate distortion-rate function with DPCM

Prediction gain

Linear prediction: smallest achievable prediction error

variance for N-dimensional signal determined by spectral

flatness

2 2 22 R

DPCM E Ed R

Variance of

prediction error 2 2

2 2

X XDPCM

E E

G

2

2 2

1 1exp ln

2

EXXN

X X

d

Page 23: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 23

Predictive coding gain (cont.)

1-D Gaussian Markov-1 process with correlation coefficient r

Autocorrelation function

Prediction gain 2

1

1DPCMG

r

2 k

n n k XE X X r

Example

Page 24: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 24

0 1 2 3 4 5 6 7 0

5

10

15

20

25

30

35

Panter & Dite App

Entropy-Constrained Opt.

D(R); =0.9 DPCM & ECSQ

R [bits]

2

10

SNR [dB]

10 log X

D

• Linear predictor,

order N=1, a=0.9 • Entropy-Constrained

Scalar Quantizer with

Huffman VLC

• Iterative design

algorithm applied

R-D curves for Gauss-Markov-1 source

1010 log 1.53 dB6

e

10 2

110 log 7.2 dB

1 r

Page 25: No Slide Titleweb.stanford.edu/class/ee398a/handouts/lectures/06-Prediction.pdf · JPEG-LS lossless compression standard Lossy predictive coding: ... EE398A Image and Video Compression

Bernd Girod: EE398A Image and Video Compression Predictive Coding no. 25

Reading

Wiegand, Schwarz, Chapter 6

Taubman, Marcellin, 2.4.2, 3.3, Chapter 20 (JPEG-LS)

S. K. Goyal, J. B. O’Neal, “Entropy Coded Differential

Pulse-Code Modulation Systems for Television Systems,”

IEEE Trans. Communications, pp. 660-666, June 1975.

N. Farvadin, J. W. Modestino, “Rate-distortion performance

of DPCM schemes for autoregressive sources,” IEEE

Trans. Information Theory, vol. 31, no. 3, pp. 402-418, May

1985.