Mahir Hassan
Transcription
Mahir Hassan
Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Lossless Compression Algorithms 3- Entropy Coding Algorithms (Content Dependent Coding) 1- Run-length Encoding (RLE) Replaces sequence of the same consecutive bytes with number of occurrences Number of occurrences is indicated by a special flag (e.g., !) 1|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Example: Source = abcccccccccdeffffggg (20 Bytes) RLE Coded = abs! 9def! 4ggg (13 bytes) 2|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 2- Huffman Encoding Statistical encoding To determine Huffman code, it is useful to construct a binary tree Leaves are characters to be encoded Nodes carry occurrence probabilities of the characters belonging to the sub tree Example: How does a Huffman code look like for symbols with statistical symbol occurrence probabilities? P (A) = 3/20, P (B) = 11/20, P(C) = 1/20, P (D) = 3/20, P (E) = 2/20 3|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Huffman Encoding (Example) -2 Step 1: Sort all Symbols according to their probabilities (left to right) from Smallest to largest these are the leaves of the Huffman tree 4|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Compression ratio If the compression and decompression processes induce no information loss, then the compression scheme is lossless; otherwise, it is lossy. Compression ratio: Compression ratio = B0 / B1 B0 – number of bits before compression B1 – number of bits after compression Symmetric compression Requires same time for encoding and decoding used for live mode applications (teleconference) performed once when enough time is available decompression performed frequently, must be fast used for retrieval mode applications (e.g., an interactive CD-ROM) 5|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Limitations • Diverges from lower limit when probability of a particular symbol becomes high always uses an integral number of bits • Must send code book with the data Lowers overall efficiency • Must determine frequency distribution (Histogram) Must remain stable over the data set Lossless and lossy compression Compressed Data = compress (originalData) DecompressedData = decompress (compressed Data) When originalData = decompressedData, the Compression is lossless. When originalData 6|Page != decompressedData, the compression is lossy Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Lossless and Lossy Compression • Lossy compressors generally obtain much higher compression ratios than do lossless compressors. Say 100 vs. 2. • Lossless compression is essential in applications such as text file compression. • Lossy compression is acceptable in many imaging applications. in video transmission, a slight loss in the transmitted video is not noticed by the human eye. 1- Approaches of Differential Coding of Images: Distributions for Original versus Derivative Images. 7|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 4- Source Coding Algorithms 1- Shift Coding (S-code) • It is a variable encoding, • it shows a good efficiency for coding the inputs set having monastically decreasing probabilities Procedure: The S-coding process is simply, based on: 1. partitioning the range of input set values into equal region, each of them has a width (2n-1) 2. Then n-bits code words are used to index the first inputs group (having the high frequency of occurrence) 3. And 2n-bits to encode the inputs located in the 2nd region and so on. The mean length b of the code words for S-shift code could be given by the following relation, 8|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Where; p (i) is the frequency of occurrence of the input i, & div is the integer division operator. 9|Page Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. LZW compression LZW compression is the compression of a file into a smaller file using a table-based lookup algorithm invented by Abraham Lempel, Jacob Ziv, and Terry Welch. 10 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. Example 11 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 12 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 13 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 14 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 15 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 16 | P a g e Lecture 7: Lossless Compression Algorithms Mahir Hassan Multimedia 4th stage kerabala University- Science College-Computer Science …………………………………………………………………………………………………………….. 17 | P a g e
Similar documents
Mahir Hassan
Lossless Compression Algorithms Introduction Compression: the process of coding that will effectively reduce the total number of bits needed to represent certain information.
More informationMahir Hassan ..........................................................
Six most common problems with computer presentation displays: 1- Display toggle Laptops have multiple display modes. The four most common are:
More information