22
10110100 Kurs INF5080 Compression Compression Ifi, UiO Norsk Regnesentral Vårsemester 2005 Wolfgang Leister 10110100 Compression This part of the course ... ... is held at Ifi, UiO ... (Wolfgang Leister) … and at contains material from University College Karlsruhe (Peter Oel, Clemens Knoerzer)

Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

Embed Size (px)

Citation preview

Page 1: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100

Kurs INF5080C

ompr

essi

onCompression

Ifi, UiO Norsk RegnesentralVårsemester 2005Wolfgang Leister

10110100Com

pres

sion This part of the course ...

• ... is held at Ifi, UiO ...(Wolfgang Leister)

• … and at contains material from University College Karlsruhe

(Peter Oel, Clemens Knoerzer)

Page 2: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Content

• Information Theory• Data Compression

10110100Com

pres

sion Preview

• Image Formats– JPEG / JIFF– Wavelet Compression– Fractal Compression

• Video Formats– MJPEG– MPEG

Page 3: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Multimedia data types

• Images• Graphics• Video / Image sequences• Audio• 3D-Data• Text / Documents• others

10110100Com

pres

sion Multimedia data types

• Images• Graphics• Video / Image sequences• Audio• 3D-Data• Text / Documents• others

Page 4: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Lossy Coding

• Applicable only for data types like:– Images– Films (image sequences)– Audio

• Use physiological capabilities and limitations of the senses to design compression methods

10110100Com

pres

sion Capabilities of the senses

● Eye• Eye recognises frequencies• Brightness is better recognised than colours.• Movement and flicker is recognised very

strongly!● Ear

- Densely situated frequencies cover each other.

- Frequencies characteristics of the ear

Page 5: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Information Theory

• Symbols: A = a0,a1, ... aN-1

• Coding: C = c0,c1, ... cN-1

– trivial Coding (constant Code Length)• ci = bi0,bi1, ... biM-1 for i∈[0,N-1]

• bij∈{0,1} (binary)

• M = ⎡log2 N⎤ (Code length, number of bits)

• Distribution: P = p0,p1, ... pN-1

– probability for symbols

10110100Com

pres

sion Information Theory

∑−

=

−=1N

0iii0 p log pH

Information content: (Entropy)

(Basis = 2 ⇒ bit/codeword)

Example: Uniform distribution

pi1N=

logNloglogH N1

1N

0iN1

N1

0 =−=−= ∑−

=

Page 6: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Information theory

• Coding: C = c0,c1, ... cN-1 – ci = bi0,bi1, ... bili-1

• i∈[0,N-1]

• bij∈{0,1}

• li = length of code word ci

• average code length: L p l Hi i

i 0

N 1

0= ≥=

10110100Com

pres

sion Information Theory

ii pl ld−=

kl i 21

21==ip

• When is L = H0 ? i.e.: average code Length = Entropy

uniform distribution

• What if for all i ?pi1

2k≠not uniform distribution

Page 7: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Information Theory

pi1

2k≠• What if ?

–Huffman Coding–Group events into one code word:

(ai1,........,ain) → ci

– Every (ai)-combination must be available: Nn code words

–Arithmetic coding often better suitable

non uniform distribution

10110100Com

pres

sion Why Data compression?

• An image says more than a thousand words …

• An image needs more space than a thousand words …

• Data are contain redundancy ...• Humans love redundancy …

Intermezzo ...

Page 8: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encoding

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encoding

run length encoding:

000011100000000110000101111110000000000(4x0)(3x1)(8x0)(2x1)(4x0)(1x1)(1x0)(6x1)(10x0)4,3,8,2,4,1,1,6,10

Examples:PCXFaxJPEG

Page 9: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Code words have different lengthsLength of code word dependent on probability: (high probability short Codewort) (low probability long Codewort)

Global and fixed code word table

Code word table is part of coding

Page 10: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

1.Step: Events to be coded are sorted by probabilities (rising order).

2.Step: The events with least probabilities are removed from list, united to one event, and added sorted into list with sum of both probabilities.

3.Step: Repeat Step 2 until only one element is contained in list.

4.Step: Code words are generated by marking the edges in the binary tree by 0 and 1. Read the code word from top to bottom.

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

c0.4

a0.2

e0.2

b0.15

d0.05

Page 11: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

b0.15

d0.05

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

c0.4

bde0.4

a0.2

b0.15

d0.05

e0.2

Page 12: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

c0.4

bde0.4

a0.2

bdea0.6

c0.4

e0.2

b0.15

d0.05

a0.2

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

bdeac1.0

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

c0.4

bde0.4

a0.2

bdea0.6

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

Page 13: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

bdeac1.0

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

c0.4

bde0.4

a0.2

bdea0.6

c0.4

c0.4

a0.2

e0.2

b0.15

d0.05

0 1

0 10 1

0 1

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codes

Example: Huffman-Coding:

a0.2

b0.15

c0.4

d0.05

e0.2

bdeac1.0

c0.4

a0.2

e0.2

b0.15

d0.05

c0.4

a0.2

e0.2

bd0.2

c0.4

bde0.4

a0.2

bdea0.6

c0.4

c0.4

a0.2

e0.2

b0.15

d0.05

0 1

0 10 1

0 1

a 01b 0010c 1d 0011e 000

Page 14: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Method by Ziv and Lempel

Code tabelle is generated while codingNo need to transfer code tabelle

Page 15: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Example: a b c a b a b a c

1 a2 b3 c45678...

Output:w: a

a

a

b

b

ab 1

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Example: a b c a b a b a c

1 a2 b3 c45678...

Output:w: b

b

b c

ab

c

bc12

Page 16: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Example: a b c a b a b a c

1 a2 b3 c45678...

Output:w: c

c

c a

ab

a

bc12

ca

3

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Example: a b c a b a b a c

1 a2 b3 c45678...

Output:w: a

a

a

b

ab

b

bc12

ca

ab

a3

a

aba

4

Page 17: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Example: a b c a b a b a c

1 a2 b3 c45678...

Output:w: a

a

a

b

ab

b

bc12

ca

ab

a3

a

abaaba

c

c

4

abac

7

10110100Com

pres

sion Arithmetic Coding

• Symbols are represented by probability intervals

• Symbol chains are represented by a concatenation of their probability intervals

Page 18: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Arithmetic Coding

a

b

c

d

e

#

0.0

0.2

0.35

0.70.75

0.951.0

a b c d e #

0.2 0.15 0.35 0.05 0.2 0.05

AP

# = [0.95, 1.0) 0.96.. 0.11111e = [0.75, 0.95) 0.75 0.11d = [0.7, 0.75) 0.71.. 0.10111c = [0.35, 0.7) 0.5 0.1b = [0.2, 0.35) 0.25 0.01a = [0.0, 0.2) 0.125 0.001

10110100Com

pres

sion Arithmetic Coding

a

b

c

d

e

#

0.0

0.2

0.35

0.70.75

0.951.0

a b c d e #

0.2 0.15 0.35 0.05 0.2 0.05

AP

a#aeadacabaa

Page 19: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Arithmetic Coding

a

b

c

d

e

#

0.0

0.2

0.35

0.70.75

0.951.0

a b c d e #

0.2 0.15 0.35 0.05 0.2 0.05

AP

0.35

0.2

ba

bb

bc

bd

be

b#

10110100Com

pres

sion Arithmetic Coding

a

b

c

d

e

#

0.0

0.2

0.35

0.70.75

0.951.0 0.35

0.2

ba

bb

bc

bd

be

b#0.305

0.2525

bca

bcb

bcc

bcd

bce

bc#0.263

0.2525

bcaa

bcab

bcac

bcad

bcae

bca#0.263

0.262475

b c a #

Page 20: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Arithmetic Coding

a

b

c

d

e

#

0.0

0.2

0.35

0.70.75

0.951.0 0.35

0.2

ba

bb

bc

bd

be

b#0.305

0.2525

bca

bcb

bcc

bcd

bce

bc#0.263

0.2525

bcaa

bcab

bcac

bcad

bcae

bca#0.263

0.262475

0.0100001101

0100001101Huffman: 0110110(0000)

0.263 0.010000110101001110.262475 0.01000011001100001

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

QuantisierungClustering

Quantising:

Analogue Digital8 Bit 4 BitRGB Colour palette

Clustering

Page 21: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

QuantisingClustering

10110100Com

pres

sion Compression techniques

lossless

with loss

run length encodingoptimal Codesadaptive Codes

Quantising ClusteringDescriptive

Tran

sfor

mat

ion

Page 22: Seminar Multimedia Streaming 10110100 Multimedia data types • Images •Graphics • Video / Image sequences • Audio • 3D-Data •T / Dextocumsent •others Compression 10110100

10110100Com

pres

sion Image Data formats

lossless with lossPBM+GIF ?PNG

JPEG(JPEG)Wavelet Compr.Wavelet Compr.

10110100Com

pres

sion The End of Lecture