Presentation is loading. Please wait.

Presentation is loading. Please wait.

©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression.

Similar presentations


Presentation on theme: "©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression."— Presentation transcript:

1 ©Brooks/Cole, 2003 Chapter 15 Data Compression

2 ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression. Understand three lossless compression encoding techniques: run-length, Huffman, and Lempel Ziv. After reading this chapter, the reader should be able to: O BJECTIVES Understand two lossy compression methods: JPEG and MPEG.

3 ©Brooks/Cole, 2003 Figure 15-1 Data compression methods Data compression means sending or storing a smaller number of bits.

4 ©Brooks/Cole, 2003 LOSSLESSCOMPRESSIONMETHODSLOSSLESSCOMPRESSIONMETHODS 15.1

5 Lossless compression In lossless data compression, the integrity of the data is preserved. The original data and the data after compression and decompression are exactly the same because the compression and decompression algorithms are exactly the inverse of each other. Example: Run-length encoding Run-length encoding Huffman encoding Huffman encoding Lempel Ziv (L Z) encoding (dictionary-based encoding) Lempel Ziv (L Z) encoding (dictionary-based encoding)

6 ©Brooks/Cole, 2003 Figure 15-2 Run-length encoding It does not need knowledge of the frequency of occurrence of symbols and can be very efficient if data are represented as 0s and 1s. For example:

7 ©Brooks/Cole, 2003 Figure 15-3 Run-length encoding for two symbols We can encode one symbol which is more frequent than the other. This example only encode 0’s between 1’s. There is no 0 between 1’s

8 ©Brooks/Cole, 2003 Table 15.1 Frequency of characters Character A B C D E ------------------------------------------------------ Frequency1712122732 Huffman coding In Huffman coding, you assign shorter codes to symbols that occur more frequently and longer codes to those that occur less frequently. For example:

9 ©Brooks/Cole, 2003 Figure 15-4 Huffman coding

10 ©Brooks/Cole, 2003 Figure 15-5 Final tree and code

11 ©Brooks/Cole, 2003 Figure 15-6 Huffman encoding

12 ©Brooks/Cole, 2003 Figure 15-7 Huffman decoding

13 ©Brooks/Cole, 2003 Huffman coding The beauty of Huffman coding is that no code in the prefix of another code. There is no ambiguity in encoding. The receiver can decode the received data without ambiguity. Huffman code is called instantaneous ( 即時的 ) code because the decoder can unambiguously decode the bits instantaneously with the minimum number of bits.

14 ©Brooks/Cole, 2003 Lempel Ziv encoding LZ encoding is an example of a category of algorithms called dictionary-based encoding. The idea is to create a dictionary (table) of strings used during the communication session. The compression algorithm extracts the smallest substring that cannot be found in the dictionary from the remaining non- compressed string.

15 ©Brooks/Cole, 2003 Figure 15-8:Part I Example of Lempel Ziv encoding

16 ©Brooks/Cole, 2003 Figure 15-8:Part 2 Example of Lempel Ziv encoding

17 ©Brooks/Cole, 2003 Figure 15-9: Part I Example of Lempel Ziv decoding

18 ©Brooks/Cole, 2003 Figure 15-9: Part II Example of Lempel Ziv decoding

19 ©Brooks/Cole, 2003 LOSSYCOMPRESSIONMETHODSLOSSYCOMPRESSIONMETHODS 15.2

20 Lossy compression methods Loss of information is acceptable in a picture of video. The reason is that our eyes and ears cannot distinguish subtle changes. Loss of information is not acceptable in a text file or a program file. For examples: Joint photographic experts group (JPEG) Joint photographic experts group (JPEG) Motion picture experts group (MPEG) Motion picture experts group (MPEG)

21 ©Brooks/Cole, 2003 Figure 15-10 JPEG gray scale example, 640 x 480 pixels Image compression: JPEG

22 ©Brooks/Cole, 2003 Figure 15-11 JPEG process DTC: discrete cosine transform QuantizationCompression

23 ©Brooks/Cole, 2003 Figure 15-12 Case 1: uniform gray scale Discrete cosine transform T(0, 0): DC value (direct current value) T(m, n) : AC values (represent changes in the pixel values) T(0, 0)

24 ©Brooks/Cole, 2003 Figure 15-13 Case 2: two sections Discrete cosine transform

25 ©Brooks/Cole, 2003 Figure 15-14 Case 3: gradient gray scale Discrete cosine transform

26 ©Brooks/Cole, 2003 DCT discussion The DCT transformation creates table T from table P. The DC value gives the average value of the pixels. The AC values gives the changes. Lack of changes in neighboring pixels creates 0s. The DCT transformation is reversible. Appendix F (Mathematical formula for DCT transformation)

27 ©Brooks/Cole, 2003 Quantization After the T table is created, the values are quantized to reduce the number of bits needed for encoding. Quantization: Divide the number by a constant and then drop the fraction. Divide the number by a constant and then drop the fraction. The quantizing phase is not reversible. The quantizing phase is not reversible. Some information will be lost. Some information will be lost.

28 ©Brooks/Cole, 2003 Compression After quantization, the values are read from the table, and redundant 0s are removed. The reason is that if the picture does not have fine changes, the bottom right corner of the T table is all 0s. Fig. 15.15

29 ©Brooks/Cole, 2003 Figure 15-15 Reading the table

30 ©Brooks/Cole, 2003 品質 :100%

31 ©Brooks/Cole, 2003 品質 :50%

32 ©Brooks/Cole, 2003 品質 :10%

33 ©Brooks/Cole, 2003 品質 :5%

34 ©Brooks/Cole, 2003 Video compression--MPEG MPEG method Spatial compression Spatial compression The spatial compression of each frame is done with JPEG. Temporal compression Temporal compression The temporal compression removes the redundant frames. MPEG method first divides frames into three categories: I-frames, P-frames, B- frames.

35 ©Brooks/Cole, 2003 Figure 15-16 MPEG frames I-frames: (intra-coded frame) It is an independent frame that is not related to any other frame. It is an independent frame that is not related to any other frame. They are present at regular intervals. They are present at regular intervals. I-frames are independent of other frames and cannot be constructed from other frames. I-frames are independent of other frames and cannot be constructed from other frames.

36 ©Brooks/Cole, 2003 Figure 15-16 MPEG frames P-frames: (predicted frame) It is related to the preceding I-frame or P-frame. It is related to the preceding I-frame or P-frame. Each P-frame contains only the changes from the preceding frame. Each P-frame contains only the changes from the preceding frame. P-frames can be constructed only from previous I- or P-frames. P-frames can be constructed only from previous I- or P-frames. B-frames: (bidirectional frame) It is relative to the preceding and following I-frame or P-frame. It is relative to the preceding and following I-frame or P-frame. Each B-frame is relative to the past and the future. Each B-frame is relative to the past and the future. A B-frame is never related to another B-frame. A B-frame is never related to another B-frame.

37 ©Brooks/Cole, 2003 Figure 15-17 MPEG frame construction Input sequence MPEG sequence

38 ©Brooks/Cole, 2003 Key terms AC value B-frame Binary tree BranchCompression Data compression DC value Decoding decompression Dictionary-based encoding DCT Huffman coding I-frame JPEG LZ encoding Lossless data compression Lossy data compression MPEGNodeP-frameQuantization Run-length encoding Spatial compression Temporal compression


Download ppt "©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression."

Similar presentations


Ads by Google