1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture 4 DictionaryMethods

44 326 1
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Dictionary methods
Tác giả Alexander Kolesnikov
Trường học University of Example
Chuyên ngành Data Compression
Thể loại bài giảng
Năm xuất bản 2023
Thành phố Example City
Định dạng
Số trang 44
Dung lượng 346,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Lecture 4 DictionaryMethods

Trang 2

Dictionary based methods

• Statistical compression methods use a statistical model

of the data, and the quality of compression they achieve depends on how good that model is

• Dictionary-based method do not use statistical model

of data Instead they select strings of symbols and

encode each string as a token using a dictionary

• The dictionary holds strings of symbols and it may be static or dynamic (adaptive)

• To encode text one can use a (static) dictionary of the English (Finnish, etc.) language

Trang 3

Dictionary-based methods: Main idea

• Encoder: As the input is processed, develop a dictionary

and transmit the index of strings found in the dictionary

• Decoder: As the code is processed, reconstruct the

dictionary to invert the process of encoding

Trang 4

Dictionary-based methods: History

Trang 5

Sử dụng một con trỏ dịch chuyển trên xâu kí tự

đầu vào Ban đầu con trỏ trỏ vào vị trí 1

Qui ước: từ con trỏ trở về trước được gọi là quá

khứ, còn từ con trỏ trở về sau được gọi là tương lai Tránh trường hợp quá khứ dài vô tận người ta

đặt kích thước của cửa sổ quá khứ là w bằng số kí

tự dài nhất có thể trùng khớp với các kí tự trong tương lai

Trang 6

Output - thể hiện trong dạng (i, j) C:

 (i,j) thể hiện vị trí so khớp và độ dài xâu tương

ứng

 C kí tự rõ trong buffer

Trang 7

sir_sid_eastman_ea  (0,0,’s’)r’s’)) sir_sid_eastman_eas  (0,0,’s’)_’s’)) sir_sid_eastman_easi  (4,2,’s’)d’s’))

Trang 9

LZ77: Example 2

Trang 10

LZ77: Example 3

Trang 11

LZ77: Example 4

Trang 12

 Cặp (i,j) vị trí so khớp và độ dài xâu so khớp

 Kí tự vừa đọc được hoặc xâu so khớp nhưng có độ dài nhỏ hơn MIN_LENGTH

Trang 13

LZSS: Example 1

Trang 14

• This Dictionary starts (almost) empty

• The encoder add new entries to the Dictionary during

the message encoding

• The decoder decode codes using Dictionary and

add new entries to the Dictionary during decoding

Trang 15

15LZ78- Thuật toán nén

Trang 16

LZ78-Thuật toán giải nén

Trang 17

17LZ78-Example 1

Trang 18

LZW: Encoding algorithm

Initialize Dictionary with alphabet

STRING = get input character

WHILE there are still input characters DO

CHAR = get input character

IF STRING+CHAR is in the Dictionary THEN

STRING = STRING+CHAR ELSE

output the code for STRING add STRING+CHAR to Dictionary STRING=CHAR

ENDIF END of WHILE

Trang 21

output the code for STRING: 0

add STRING+CHAR=ab to Dictionary STRING=CHAR=b

ENDIF

IF STRING+CHAR=ab is in the Dictionary: No

THEN STRING = STRING+CHAR ELSE

output the code for STRING: 0 add STRING+CHAR=ab to Dictionary STRING=CHAR=b

ENDIF

Trang 22

output the code for STRING: 1

IF STRING+CHAR=ba is in the Dictionary: No

THEN STRING = STRING+CHAR ELSE

output the code for STRING: 1 add STRING+CHAR=ba to Dictionary

Trang 23

IF STRING+CHAR=ab is in the Dictionary: Yes

THEN STRING = STRING+CHAR=ab

ELSE output the code for STRING add STRING+CHAR to Dictionary STRING=CHAR

ENDIF

Trang 24

output the code for STRING: 2

IF STRING+CHAR=aba is in the Dictionary: No

THEN STRING = STRING+CHAR ELSE

output the code for STRING: 2 add STRING+CHAR=aba to Dictionary

Trang 25

IF STRING+CHAR=ab is in the Dictionary: Yes

THEN STRING = STRING+CHAR: ab

ELSE output the code for STRING add STRING+CHAR to Dictionary STRING=CHAR

ENDIF

Trang 26

IF STRING+CHAR=aba is in the Dictionary: Yes THEN

STRING = STRING+CHAR: aba

ELSE output the code for STRING add STRING+CHAR to Dictionary

Trang 27

output the code for STRING: 4

add STRING+CHAR=abab to Dictionary STRING=CHAR= b

ENDIF

IF STRING+CHAR=abab is in the Dictionary: No THEN

STRING = STRING+CHAR ELSE

output the code for STRING: 4 add STRING+CHAR=abab to Dictionary STRING=CHAR= b

ENDIF

Trang 28

IF STRING+CHAR=ba is in the Dictionary: Yes THEN

STRING = STRING+CHAR: ba

ELSE output the code for STRING add STRING+CHAR to Dictionary

Trang 30

LZW: Decoding

Initialize Dictionary

Input code c

Decode code c (index) to w

Output decoded string w

Put w? in Dictionary

REPEAT

a) Input code c

Decode the 1st symbol s1 of the code c

Complete the previous Dictionary entry with s1

b) Finish decoding the remainder of the code c

Output decoded string w

Trang 32

Input code c=0

Decode code c to w=a

Output decoded string w=a

Put w?=a? in Dictionary

Trang 33

a) Input code c=1

Decode the 1st symbol s1=b of the code c=1

Complete the previous Dictionary entry with s1=b

Trang 34

Put put w?=b? in Dictionary

b) Finish decoding the remainder of the code c=1

Output decoded string w=b

Put put w?=b? in Dictionary

Trang 35

a) Input code c=2

Decode the 1st symbol s1=a of the code c=2

Complete the previous Dictionary entry with s1=a

Trang 36

Put put w?=ab? in Dictionary

a) Finish decoding the remainder of the code c=2

Output decoded string w=ab

Put put w?=ab? in Dictionary

Trang 37

 Decode the 1st symbol s 1 =a of the code c=4

Complete the previous Dictionary entry with s1=a

a) Input code c=4

Decode the 1st symbol s 1 =a of the code c=4

Complete the previous Dictionary entry with s1=a

Trang 38

LZW: Example (4a) step 2

 Complete the previous Dictionary entry with s 1 =a

a) Input code c=4

Decode the 1st symbol s1=a of the code c=4

Complete the previous Dictionary entry with s 1 =a

Trang 39

Put put w?=aba? in Dictionary

b) Finish decoding the remainder of the code c=4

Output decoded string w=aba

Put put w?=aba? in Dictionary

Trang 40

a) Input code c=3

Decode the 1st symbol s1=b of the code c=3

Complete the previous Dictionary entry with s1=b

Trang 41

Put put w?=ba? in Dictionary

b) Finish decoding the remainder of the code c=3

Output decoded string w=ba

Put put w?=ba? in Dictionary

Trang 42

LZW: Example (6a) step 1

Decode the 1st symbol s 1 =b of the code c=6

Complete the previous Dictionary entry with s =b

Trang 43

 Complete the previous Dictionary entry with s 1 =b

a) Input code c=6

Decode the 1st symbol s1=b of the code c=6

Complete the previous Dictionary entry with s 1 =b

Trang 44

a) Finish decoding the remainder of the code c=6

Output decoded string w=bab

Ngày đăng: 26/10/2012, 11:57

TỪ KHÓA LIÊN QUAN