Fax machine HUFFMAN compression coding

zhaozj2021-02-17  74

CCITT GROUP 3 Modified Huffman Run Length ENCODEING

This compression method is originally a fax machine compression coding method set by CCITT, which is FACSIMile Compatible CCITT Group3. However, this compression method reduces the special code on some fax machines. This compression method can only compress the handling black and white image data. This compression method is to use a BITS number unfixed encoding to replace a string white point or black spot that continuously appears in black and white image data.

All encoded BITS values ​​are from the following three forms:

Terminating Codes

Make-Up Codes

Additional make-up cots

(1) Terminating Codes represents the encoding of the 0-63 consecutive white point or black. Within this range, there is no corresponding encoding without a white point or black.

(2) Make-Up Codes represents the 64-1728 encoding of the continuous white or black spots. Within this range, there is a corresponding encoding every 64 points or black dots.

(3) Additional make-up Codes represents the 1792-2560 encoding of continuous white or black spots. Within this range, a corresponding encoding is shared every 64 points or black spots.

Table 1a. Terminating White Codes

Code LNG RUN

---------------------------

00110101 8 0

000111 6 1

0111 4 2

1000 4 3

1011 4 4

1100 4 5

1110 4 6

1111 4 7

10011 5 8

10100 5 9

00111 5 10

01000 5 11

001000 6 12

000011 6 13

110100 6 14

110101 6 15

101010 6 16

101011 6 17

0100111 7 18

0001100 7 19

0001000 7 20

0010111 7 21

0000011 7 22

0000100 7 23

0101000 7 24

0101011 7 25

0010011 7 26

0100100 7 27

0011000 7 28

00000010 8 29

00000011 8 30

00011080 8 31

00011011 8 32

00010010 8 33

00010011 8 34

00010100 8 35

00010101 8 3600010110 8 37

00010111 8 38

00101000 8 39

00101001 8 40

00101010 8 41

00101011 8 42

00101100 8 43

00101101 8 44

00000100 8 45

00000101 8 46

00001010 8 47

00001011 8 48

01010010 8 49

01010011 8 50

01010100 8 51

01010101 8 52

00100100 8 53

00100101 8 54

01011000 8 55

01011001 8 56

01011010 8 57

01011011 8 58

01001010 8 59

01001011 8 60

00110010 8 61

00110011 8 62

00110100 8 63

Table 1b. Make Up White Codes

Code LNG RUN

---------------------------

11011 5 64

10010 5 128

010111 6 192

0110111 7 256

00110110 8 320

00110111 8 384

01100100 8 448

01100101 8 512

01101000 8 576

01100111 8 640

011001100 9 704

011001101 9 768

011010010 9 832

011010011 9 896

011010100 9 960

011010101 9 1024

011010110 9 1088

011010111 9 1152

011011000 9 1216

011011001 9 1280

011011010 9 1344

011011011 9 1408

010011000 9 1472

010011001 9 1536

010011010 9 1600

011000 6 1664

010011011 9 1728

Table 2a. Terminating Black Codes

Code LNG RUN

--------------------------- 0000110111 10 0

010 3 1

11 2 2

10 2 3

011 3 4

0011 4 5

0010 4 6

00011 5 7

000101 6 8

000100 6 9

0000100 7 10

0000101 7 11

0000111 7 12

00000100 8 13

00000111 8 14

000011000 9 15

0000010111 10 16

0000011000 10 17

0000001000 10 18

00001100111 11 19

00001101000 11 20

00001101100 11 21

00000110111 11 22

00000101000 11 23

00000010111 11 24

00000011000 11 25

000011001010 12 26

000011001011 12 27

000011001100 12 28

000011001101 12 29

000001101000 12 30

000001101001 12 31

000001101010 12 32

000001101011 12 33

000011010010 12 34

000011010011 12 35

000011010100 12 36

000011010101 12 37

000011010110 12 38

000011010111 12 39

000001101100 12 40

000001101101 12 41

000011011010 12 42

000011011011 12 43

000001010100 12 44

000001010101 12 45

000001010110 12 46

000001010111 12 47

000001100100 12 48

000001100101 12 49

000001010010 12 50

000001010011 12 51

000000100100 12 52

000000110111 12 53

000000111000 12 54

000000100111 12 55

000000101000 12 56

000001011000 12 57

000001011001 12 58

000000101011 12 59

000000101100 12 60

000001011010 12 61000001100110 12 62

000001100111 12 63

Table 2b. Make Up Black Codes

Code LNG RUN

---------------------------

0000001111 10 64

000011001000 12 128

000011001001 12 192

000001011011 12 256

000000110011 12 320

000000110100 12 384

000000110101 12 448

0000001101100 13 512

0000001101101 13 576

0000001001010 13 640

0000001001011 13 704

0000001001100 13 768

0000001001101 13 832

0000001110010 13 896

0000001110011 13 960

0000001110100 13 1024

0000001110101 13 1088

0000001110110 13 1152

0000001110111 13 1216

0000001010010 13 1280

0000001010011 13 1344

0000001010100 13 1408

0000001010101 13 1472

0000001011010 13 1536

0000001011011 13 1600

0000001100100 13 1664

0000001100101 13 1728

Table 3. Extended Make Up Codes (Black and White)

Code LNG RUN

---------------------------

00000001000 11 1792

00000001100 11 1856

00000001101 11 1920

000000010010 12 1984

000000010011 12 2048

000000010100 12 2112

000000010101 12 2176

000000010110 12 2240

000000010111 12 2304

000000011100 12 2368

000000011101 12 2432

000000011110 12 2496

0000000111112 12 2560

Anyone who wants to use this compression method to handle black and white image data must now save these three forms, so that the program can refer to these forms to identify the correct encoding, prepared to compress data.

During the process of compressed compressed data, the first step is to store a white point encoding first. If the first bit value of the image data is a black point, the continuous white point encoding (00110101) of the number of points is 0, and then the coding of the black point is started. This is a special provision of this compression method: the first coding value of each line must be encoded in a continuous white point. The next question is how to replace image data in encoding within the above table? Below, the first two lines of one image data are as follows: The first column 15 hollow, 625 white points, 3360 black dots

Postal code: 00110100000000110010 000000000111111

0 white points 15 black spots 576 white points 49 white points 2560 black spots

011001101 000001101010 000000

768 black spots 32 black spots 6 bits

The second list 18 white points, 1486 black spots, 2496 white points

coding:

0100111 0000000010101011 0000001111 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101011010101

18 white points 1472 black spots 14 black spots 2496 white dots 0 white dots

From the coded data listed above, you can summarize the following four coding principles:

(1) The first encoding of each line is compressed, and it must be encoded in a continuous white point. Even if the first point in each line is a black point, you must first use 00110101 (0 white points) as the first encoding of the compressed data, then start the first encoding of the data, and then store the true representative graphic black. Point code;

(2) The total number of BITS of each line is required to be 8 multiple. If the total number of BITS is not 8 times, it is necessary to compress the end of the data per line, plus a bits having a value of 0, is a multiple of the BITS total number of 8. For example, the total number of BITS of the first row of the above instance is 66, and the six bits are lacking, in order to become a multiple of 8, the end of the first column compressed data, adding six values ​​0, which enables the total number of BITS to reach 72, enough to be 8 times. As for the total number of BITS of the second line of compressed data, it is exactly the multiple of 8, so there is no need to add some extra BITS.

(3) There are three types of encoding.

(A) Number of points does not exceed 63, and you can refer to the Terminating Codes form to find the corresponding encoding. This coding is only one, which instead of a string of the same points.

(B) If the number is between 64-1728, it is found according to Terminating Codes and Make-Up Codes forms. If the number of points is not equal to the value of the Make-Up Codes table, it is necessary to use two encodings to replace a string of the same points.

(C) The number of points is more than 1792, and you must refer to three forms at the same time to find the code you want. At this time, the encoding of a string of the same value may require three. If you have a lot of points than 2560, you need to encode, just three.

(4) The encoding in the Additional Mak-Up Codes table can represent a continuous white point or black point, so the encoding of this table is to bring the encoding of two tables, in order to let the decompression program know what exactly The read code is a representative white point or a black point. For example, the second row of the above example has a string of dotted points of 2496, just the same value as the 12th point in the Additional MAK-UP CODES table. Therefore, after 000000011110 (2496 consecutive white points or black spots), plus 00110101 (0 white points), indicating that 000000011110 represents 2496 continuous white points. The above is taken from the "Mystery of Exploring Image Files" Li Zhenhui and RFC804

my experience:

When a continuous white point or black spot is only used as Make-Up Codes or

Additional make-up CODES When these two forms, must be added 00110101 (0 white points) or 0000110111 (0 black points)

E.g:

1792 white points

Postal code: 000000001010101010101011010

1792 white points 0 white points 5 bits

128 black spots

Code: 00110 000011011100

0 white dots 128 black dots 0 black dots 2 bits

2624 white points

Code 0000000111111010101010101010101010101010101010101010101010101110101010

2560 white point 64 white dots 0 white dots 7 bits

2625 white points

Code 0000000111111 11011 000111 0

2560 white points 64 white points 1 white point 1 bits

转载请注明原文地址:https://www.9cbs.com/read-30008.html

New Post(0)