Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

150:

150:

150




2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

(lossless compression)

Huffman

[1999]: 9, 9.1-9.6

Gonzales [2002]: Chapter 8, Sections 8.1-8.4

Gonzales [2004]: Chapter 8, Sections 8.1-8.3

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman


(
, , , )

-
.


(
.


bits


pixel .
bits
2005 Nicolas Tsapatsoulis

150:
150:

-



uffman


CD-ROM;
:

(.. )
;

PSTN (modem 56kbs);

ISDN (2x64 kbps);

A ADSL (256 kbps 2 Mbps);

LAN (10 Mbps, 100Mbps);

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

(II);


animation ;

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

4800 =>

~4,8 kbytes ASCII

~9,6 kbytes Unicode

500 =>

(2 x 10 bits),
(2 x 10 bits) 8 bits

=> 500 x 48 bits ~= 3 kbytes

640 x 480 pixels 256 => 640 x 480


x 1 byte ~= 307 kbytes

(3 bytes per pixel) => 640 x 480 x 3


byte ~= 921 kbytes
2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

()

=> ~ 8 kbyte / sec

CD => 1,411 Mbps => ~ 176 kbyte / sec

CD-ROM :

74 , CD

... 20

(.. PAL system) =>

(HDTV) ( ,
aspect ratio 16:9 4:3)=>

625 lines x 840 pixel /line x 3 bytes /pixel x 25 frames () /sec => 39
Mbyte / sec

5.33 x => 208 Mbyte / sec

120 GB 60

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

bandwidth
( )

bits (.. ,
)

g di
mi g(di) = mi

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

(II)

gr mi
dr gr(mi) = dr

Trade-off: vs.

(lossless compression algorithms)

(lossy compression algorithms)

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

/
150
msecs (end-to-end delay)

50 msecs
face-to-face

end-to-end


, ,
/ .
2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

()


(Retrieval Mode)

(forward and backward)


,
0,5 sec

(
)

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman


.
:

pixel

pixel
bits

pixels (
). H pixel
.

pixel
.

(texture - pattern)
, .

- :

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

Bits pixel (P Bits Per Pixel) bits


pixel

- BPP = log2(K) = B:
K = (. 256 [0
255].
B = log2(256) = 8.

bits pixel
(Variable Length
Coding VLC).

B(x, y) = bits
pixel f(x,y).
: BPP =

1
MxN

M 1 N 1

B( x, y)
x =0 y =0

, f
2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

O Btotal bits
f pixel
. (header)
:

(, ,
)

BPP :

BPP =

(II)

1
Btotal
MxN

CR (Compression Ratio) (
bits per pixel ):

CR =

B
BPP
2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman



bits per pixel

=1 (binary images), =8
(indexed)
=24 (full color RGB).

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman

(8) rk (k=0..7)
.

B
bits per pixel ..: 2 8. =3.

pr(rk)
( ;)


bits
BPP<B.
.

o BPP ;

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

pixel


pixel
.




(
)

pixel





pixel




bits.

2005 Nicolas Tsapatsoulis


150:
150:

-



uffman


(Psychvisual redundancy)

.
JPEG ,
,

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman

(lossless compression schemes):


=>
.


/
(.. ).

(lossy compression schemes):


( ,
).


.
2005 Nicolas Tsapatsoulis

10


150:
150:

-



uffman


()

(entropy encoding):


.
.

(source encoding):

.
pixel .

(hybrid encoding):

,
(
2005 Nicolas Tsapatsoulis
)

150:
150:

-



uffman

(Run Length Encoding)

RLC (Run Length Coding)

Zero Suppression

Huffman

packbits encoding (.. LZW, LUT)

2005 Nicolas Tsapatsoulis

11


150:
150:

-



uffman

DPCM (Difference Pulse Code Modulation)

DM (Difference Modulation)

FFT (Fast Fourier Transform)

DCT (Discrete Cosine Transform)

(Layered)

Subband Coding

Quadtree

Fractals

2005 Nicolas Tsapatsoulis

150:
150:

-



uffman


(coding standards)

JPEG (Joint Photographic Experts Group)

(DCT) (RLC)

H263 ( ):
(DCT), (
MC: motion compensation) (RLC)

MPEG (Moving Pictures Expert Group) - ( , ):

(DCT), (
MC: motion compensation), (RLC)
(Subband Coding) (MP3).

2005 Nicolas Tsapatsoulis

12


150:
150:

;
;

-



uffman

.
:

(Mapping)
(.. ,
pixel )

(Quantization)

(Encoder)
()

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;

-



uffman


2:1 CR 3:1

variable length encoding


() .


2005 Nicolas Tsapatsoulis
.

13


150:
150:

;
;
;

-



uffman

(entropy)

() bits pixel ( )
.

;
K

Shannon:

E=

P log
k

Pk

k =1

K o ()
Pk k.

Pk;

Pk=HI(k) = n/(xN),
k = 0, ... K-1,
k () n I,
( xN pixels) K .
2005 Nicolas Tsapatsoulis

150:
150:

;
;
;

-



uffman


(II)

( ),
,
.

bits
pixel (BPP).

H BPP (
) :
K 1

BPP =

N H
k

I (k )

k =0

o
, I(k) k k bits
k.

2005 Nicolas Tsapatsoulis

14


150:
150:

;
;
;

-



uffman

Pk = H I ( k ) =

1
K

K = 2B
K 1

E{ I } =

K log { K } = B
2

k =0

I .
I ;

( )
2005 Nicolas Tsapatsoulis

150:
150:

;
;
;

-



uffman

()

: 0 {}



: BPP {}

.. E{} = B
.

, (;)


( ) ..
pixels

Pk

,
2005 Nicolas Tsapatsoulis

15


150:
150:

;
;
;

-



uffman

5 = 32,
= 68, C =145, D =190, E = 225
P(A)=0.4, P(B)=0.08, P(C)=0.16,
P(D)=0.16, P(E)=0.2.

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;

-



uffman

Huffman

(
)

2005 Nicolas Tsapatsoulis

16


150:
150:

;
;
;
;

-



uffman

Huffman ()

Huffman:
ki Pki

(0) ki Pki = 0

(1) 2 pi= Pki pj= Pkj

(2) pij = pi + pj ( , )

(3) :

ki '1' kj '0'

4) 1 ()
(1)

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;

-



uffman


Huffman ()
P(ADCEB)=1.00

P(A)=0.16

011

P(B)=0.51

P(C)=0.09

000

P(D)=0.13

010

P(E)=0.11

001

P(ADCE)=0.49

0
P(CE)=0.20

0
P(C)=0.09

1
P(E)=0.11

P(B)=0.51

1
P(AD)=0.29

0
P(D)=0.13

1
P(A)=0.16

2005 Nicolas Tsapatsoulis

17


150:
150:

;
;
;
;

-



uffman


Huffman ()

K = 8 {0 ,.., 7}
. :

p(0) = 1/2

p (4) = 1/16

p(1) = 1/8

p (5) = 1/32

p(2) = 1/8

p (6) = 1/32

p (3) = 1/8

p (7) = 0


Huffman
bit pixel BPP

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;

-



uffman


Huffman

Huffman .
bits


bits:
00010110101110000010000100010110111010

:
CBADBBBCECDEAABD

P(A)=0.16

011

P(B)=0.51

P(C)=0.09

000

P(D)=0.13

010

P(E)=0.11

001

2005 Nicolas Tsapatsoulis

18


150:
150:

;
;
;
;

-



uffman


Huffman

Huffman
2:1 CR 3:1

Huffman (
)

bit
:
00010110100110000010000100010110111010
;


. .


Huffman,
, Huffman.


Huffman.
2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;

-



uffman


Huffman

A,B,C,D,E


0.4

0.08

0.16

0.16

0.2

2005 Nicolas Tsapatsoulis

19


150:
150:

;
;
;
;
;

-



uffman

,
uffman, .

a1a2..an ai
Huffman

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;

-



uffman

()

f
pixel ([0 1 2 3 4 5 6 7]) :

[0.2188 0.25 0.09375 0.1875 0.09375 0.1563 0 0].

1 : =2.4912 bit/pixel

Huffman :

0 => 01, 1 => 10, 2 => 001, 3 => 111, 4 => 000, 5 => 110

BPP = 2.5313 bit/pixel


pixel (4,1), (3,5), , (1,5):
Hi sto g ra m of Ima g e f

0 .25

4
0
f =
0

1 3 5 5 0 1 0
2 4 2 3 1 0 5

5 4 0 2 1 1 3

5 3 1 0 3 1 5

Probability of Occurence

0 .2

0 .15

0 .1

0 .05

3
4
V a lu e o f Pi xe l

2005 Nicolas Tsapatsoulis

20


150:
150:

;
;
;
;
;

-



uffman


(I)

[0,1]
:

[0 0.2188 0.4688 0.5625 0.75 0.8438 1 1 1].

4 [0.75 0.8438]

4
, .. 0.1101 =>
0.8125, 1101 4.

41, [0.75 0.8438]


:
[0.75 0.8438] =>[0.75 0.7705 0.794 0.8028 0.8204 0.8291 0.8438 0.8438 0.8438]

1 8 ,
41
[0.7705 0.794]

0.11001 =>0.7813, 11001


41
2005 Nicolas Tsapatsoulis

150:
150:

-



uffman


(V)

pixel
f :

BPP = 1.8125 bit/pixel.

1
(=2.4912 bit/pixel). ;

1 bits/pixel
pixel
Hi sto g ra m of Ima g e f
0 .25

4
0
f =
0

1 3 5 5 0
2 4 2 3 1
5 4 0 2 1
5 3 1 0 3

1
0
1
1

0
5

0 .2

Probability of Occurence

;
;
;
;
;

0 .15

0 .1

0 .05

3
4
V a lu e o f Pi xe l

2005 Nicolas Tsapatsoulis

21


150:
150:

;
;
;
;
;

-



uffman

(Huffman,
)
:


( <2)


(.. )


pixel
( pixel)

- (binary images)
pixel
0 1.

pixels

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;

-



uffman


(II)

2005 Nicolas Tsapatsoulis

22


150:
150:

;
;
;
;
;

-



uffman


()

pixel

pixels

pixels

pixels
,

....

:
[1111111111000000000000000000111111111111111111000000000000
0001111111111]

: 10 18 19 15 10

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;

-



uffman


(V)

1 byte
5 bytes:

() 72 pixels

1 bit/pixel => 9 bytes

: CR = 9 / 5 = 1.8

(.. Huffman)

Huffman
2 CR 3

Huffman
FAX.
2005 Nicolas Tsapatsoulis

23


150:
150:

;
;
;
;
;

-



uffman


(V)


(
RGB );

(flag):

[255 255 255 255 123 123 122 122 122 122 122 88 77 76]
: 255!4 123 123 122!5 88 77 66

pixel


bit pixels:

[0 255]
pixel 8 bits

(bit planes) bits pixel

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;

-



uffman


Bit Planes

2005 Nicolas Tsapatsoulis

24


150:
150:

;
;
;
;
;

-



uffman


(packbits encoding)

pixel
(codewords)

(pattern substitution packbits encoding)


,
( ):
E , T , TH, A, S , RE, IN, HE

LZW (Lempel, Ziv &


Welch) .

LZW format TIFF, GIF, BMP

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;

-



uffman

()

(.. ):
123 145 201 4 119 89 243 245 59 11 206 145 201 4 243 245 ...


:
123 256 119 89 257 59 11 206 256 257 ...
:
145 201 4 => 256
243 245 => 257

2005 Nicolas Tsapatsoulis

25


150:
150:

;
;
;
;
;

-



uffman

LZW

LZW

( 255
pixel
[0 255])
pixel







2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;
;

-



uffman

pixel pixel
:

pixel


pixel pixel
Histogram of pixel differ ences of the Cameraman Image

Histogram of Cameraman Image

10000

1800

9000

1600

8000

1400

Probability of Occurence

Probability of Occurence

7000

1200

1000

800

600

6000

5000

4000
3000

400

2000

200

1000

50

100

150
Value of Pixel

200

250

0
-100

-80

-60

-40

-20
0
20
Value of Pixel difference

40

60

80

100

2005 Nicolas Tsapatsoulis

26


150:
150:

;
;
;
;
;
;

-



uffman


(II)

( pixel)
(
pixel)

(x,y) pixel (x,y).


:
)
)
f ( x, y 1) + f ( x 1, y )
f ( x 1, y 1)
f ( x, y ) =

f ( x, y ) = 0.75 ( f ( x, y 1) + f ( x 1, y ) )
2

2
)
f ( x, y ) = f ( x, y 1)

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;
;

-



uffman


()
8
8
f =
8

8
8
8
8

9
8
8
8

8
8
8
9

9
8
9
9

9 9
8 8
9 9
9 10

)
f ( x, y ) = f ( x , y 1)

10
9

11

13

8
) 8
f =
8

9
8

8 8 8 8 9 9 9

8 8 8 9 9 9 10

8 8 9 8 9 9
8 8 8 8 8 8

( )
:
)
d ( x, y ) = f ( x, y ) f ( x , y )

8
8
d =
8

0 1 1 1 0 0 1
0 0 0 0 1

0 0 0 1 0 0 2

0 0 1 0 0 1 3
0 0

2005 Nicolas Tsapatsoulis

27


150:
150:

;
;
;
;
;
;

-



uffman


(V)





pixel

=>



( )

2005 Nicolas Tsapatsoulis

150:
150:

;
;
;
;
;
;
;

-



uffman


(, , )

Huffman

2005 Nicolas Tsapatsoulis

28

You might also like