Código de Huffman. Código aritmético Run-Length Encoding (RLE)

31
Código de Huffman Código de Huffman

Transcript of Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Page 1: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Código de HuffmanCódigo de Huffman

Page 2: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Código de HuffmanCódigo de Huffman

Page 3: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Código aritméticoCódigo aritmético

Page 4: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Run-Length Encoding (RLE)Run-Length Encoding (RLE)

Page 5: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codificação preditivaCodificação preditiva

• Predictive Coding

transmit the difference between

estimate of future sample &

the sample itself.

- Delta modulation

- DPCM

- Adaptive predictive coding

- Differential frame coding

Page 6: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Differential Pulse Code Differential Pulse Code Modulation (DPCM) Modulation (DPCM)

Page 7: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Delta ModulationDelta Modulation

+-

f (t)

y (t)

x(t) (t)

Page 8: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Delta modulationDelta modulation

f(t)t

y(t)

x(t)

Page 9: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codificação de planos de bitCodificação de planos de bit

a b c d e f

f

e

d

c

b

a

Page 10: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codificação por Codificação por transformaçãotransformação• Transform Coding

- transform image

- code the coefficients of the transform

- transmit them

- reconstruct by inverse transform

• Benefits

- transform coeff. relatively uncorrelated

- energy is highly compacted

- reasonable robust relative to

channel errors

Page 11: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Padrão JPEGPadrão JPEG

"Joint Photographic Expert Group". "Joint Photographic Expert Group". Voted as international standard in Voted as international standard in 1992. 1992.

Works with color and grayscale Works with color and grayscale images, e.g., satellite, medical, ... images, e.g., satellite, medical, ...

Lossy and losslessLossy and lossless

Page 12: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

JPEG (intraframe)JPEG (intraframe)

First generation JPEG uses First generation JPEG uses DCT+Run length Huffman entropy DCT+Run length Huffman entropy coding.coding.

Second generation JPEG Second generation JPEG (JPEG2000) uses wavelet transform (JPEG2000) uses wavelet transform + bit plane coding + Arithmetic + bit plane coding + Arithmetic entropy coding.entropy coding.

Page 13: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Visão geral JPEGVisão geral JPEG

DCT (Discrete Cosine Transformation)Quantization zigzag Scan

DPCM on DC componentRLE on AC Components

Entropy Coding

Page 14: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Porquê DCT e não DFTPorquê DCT e não DFT

• DCT is similar to DFT, but can provide a better approximation with fewer coefficients

• The coefficients of DCT are real valued instead of complex valued in DFT.

• DCT reduces Gibbs effect between sub-image boundaries.

Page 15: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Porquê DCT e não DFTPorquê DCT e não DFT

Page 16: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

DCTDCT

Transformada discreta de cosseno

Inversa:

Page 17: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Funções base DCT de 8x8Funções base DCT de 8x8

• Each 8x8 block can be looked at as a weighted sum of these basis functions.

• The process of 2D DCT is also the process of finding those weights.

Page 18: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

DCTDCT

Page 19: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

QuantizaçãoQuantização

F'[u, v] = round ( F[u, v] / q[u, v] ). F'[u, v] = round ( F[u, v] / q[u, v] ). Why? -- To reduce number of bits per Why? -- To reduce number of bits per sample sample

Example: 101101 = 45 (6 bits). Example: 101101 = 45 (6 bits). q[u, v] = 4 --> Truncate to 4 bits: q[u, v] = 4 --> Truncate to 4 bits: 1011 = 11. 1011 = 11.

Quantization error is the main source Quantization error is the main source of the Lossy Compression. of the Lossy Compression.

Page 20: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Tabelas de quantizaçãoTabelas de quantização

Luminância Cromaticidades

Um fator de qualidade multiplica a matriz de quantização.

Page 21: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Varredura Zig-Zag Varredura Zig-Zag

Why? -- To group low frequency Why? -- To group low frequency coefficients in top of vector.coefficients in top of vector.

Maps 8 x 8 to a 1 x 64 vector.Maps 8 x 8 to a 1 x 64 vector.

Page 22: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codifica DC com DPCMCodifica DC com DPCM

DC component is large and varied, DC component is large and varied, but often close to previous value. but often close to previous value.

Encode the difference from previous Encode the difference from previous 8 x 8 blocks -- DPCM 8 x 8 blocks -- DPCM

Page 23: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codifica AC com RLECodifica AC com RLE

1 x 64 vector has lots of zeros in it 1 x 64 vector has lots of zeros in it Keeps Keeps skipskip and and valuevalue, where , where skipskip is is

the number of zeros and the number of zeros and valuevalue is the is the next non-zero component. next non-zero component.

Send (0,0) as end-of-block sentinel Send (0,0) as end-of-block sentinel value. value.

Page 24: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Codificação entrópicaCodificação entrópica Categorize DC values into SIZE (number of Categorize DC values into SIZE (number of

bits needed to represent) and actual bits. bits needed to represent) and actual bits. ExampleExample: if DC value is 4, 3 bits are needed. : if DC value is 4, 3 bits are needed. Send off SIZE as Huffman symbol, followed by Send off SIZE as Huffman symbol, followed by

actual 3 bits. actual 3 bits. For AC components two symbols are used: For AC components two symbols are used:

Symbol_1: (Symbol_1: (skip, SIZEskip, SIZE), Symbol_2: actual bits. ), Symbol_2: actual bits. Symbol_1 (Symbol_1 (skip, SIZEskip, SIZE) is encoded using the ) is encoded using the Huffman coding, Symbol_2 is not encoded. Huffman coding, Symbol_2 is not encoded.

Huffman Tables can be custom (sent in Huffman Tables can be custom (sent in header) or default. header) or default.

Page 25: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Categorias de codificaçãoCategorias de codificaçãoSize Amplitude

  -1.1

2 -3..-2,2..3

3 -7..-4,4..7

4 -15..-8,8..15

5 -31..-16,16..31

6 -63..-32,32..63

7 -127..-64,64..127

8 -255..-128,128..255

9 -511..-256,256..511

10 -1023..512,512..1023

Page 26: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

Código de luminânciaCódigo de luminânciaCategoria Tamanho Code

0 5 00

1 3 010

2 4 011

3 5 100

4 7 101

5 8 110

6 10 1110

7 12 11110

8 14 111110

9 16 1111110

10 18 11111110

11 20 111111110

Page 27: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

ExemploExemplo

Page 28: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

JPEG 2000JPEG 2000

Page 29: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

ExemplosExemplos

Original

Page 30: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

ExemplosExemplos

JPEG

27:1

Page 31: Código de Huffman. Código aritmético Run-Length Encoding (RLE)

ExemplosExemplos

JPEG2000

27:1