Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Technology, Art & Photos
  • Be the first to comment


  1. 1. Why Compress? <ul><li>To reduce the volume of data to be transmitted (text, fax, images) </li></ul><ul><li>To reduce the bandwidth required for transmission and to reduce storage requirements (speech, audio, video) </li></ul>
  2. 2. Compression <ul><li>How is compression possible? </li></ul><ul><ul><li>Redundancy in digital audio, image, and video data </li></ul></ul><ul><ul><li>Properties of human perception </li></ul></ul><ul><li>Digital audio is a series of sample values; image is a rectangular array of pixel values; video is a sequence of images played out at a certain rate </li></ul><ul><li>Neighboring sample values are correlated </li></ul>
  3. 3. Redundancy <ul><li>Adjacent audio samples are similar (predictive encoding); samples corresponding to silence (silence removal) </li></ul><ul><li>In digital image, neighboring samples on a scanning line are normally similar (spatial redundancy) </li></ul><ul><li>In digital video, in addition to spatial redundancy, neighboring images in a video sequence may be similar (temporal redundancy) </li></ul>
  4. 4. Human Perception Factors <ul><li>Compressed version of digital audio, image, video need not represent the original information exactly </li></ul><ul><li>Perception sensitivities are different for different signal patterns </li></ul><ul><li>Human eye is less sensitive to the higher spatial frequency components than the lower frequencies (transform coding) </li></ul>
  5. 5. Classification <ul><li>Lossless compression </li></ul><ul><ul><li>lossless compression for legal and medical documents, computer programs </li></ul></ul><ul><ul><li>exploit only data redundancy </li></ul></ul><ul><li>Lossy compression </li></ul><ul><ul><li>digital audio, image, video where some errors or loss can be tolerated </li></ul></ul><ul><ul><li>exploit both data redundancy and human perception properties </li></ul></ul><ul><li>Constant bit rate versus variable bit rate coding </li></ul>
  6. 6. Entropy <ul><li>Amount of information I in a symbol of occurring probability p : I = log 2 (1/p) </li></ul><ul><li>Symbols that occur rarely convey a large amount of information </li></ul><ul><li>Average information per symbol is called entropy H </li></ul><ul><li>H = p i x log 2 (1/p i ) bits per codeword </li></ul><ul><li>Average number of bits per codeword = N i p i where N i is the number of bits for the symbol generated by the encoding algorithm </li></ul><ul><li> </li></ul>
  7. 7. Huffman Coding <ul><li>Assigns fewer bits to symbols that appear more often and more bits to the symbols that appear less often </li></ul><ul><li>Efficient when occurrence probabilities vary widely </li></ul><ul><li>Huffman codebook from the set of symbols and their occurring probabilities </li></ul><ul><li>Two properties: </li></ul><ul><ul><li>generate compact codes </li></ul></ul><ul><ul><li>prefix property </li></ul></ul>
  8. 8. Run-length Coding <ul><li>Repeated occurrence of the same character is called a run </li></ul><ul><li>Number of repetition is called the length of the run </li></ul><ul><li>Run of any length is represented by three characters </li></ul><ul><ul><li>eeeeeee7tnnnnnnnn </li></ul></ul><ul><ul><li>@e7t@n8 </li></ul></ul>
  9. 9. Lempel-Ziv-Welch (LZW) Coding <ul><li>Works by building a dictionary of phrases from the input stream </li></ul><ul><li>A token or an index is used to identify each distinct phrase </li></ul><ul><li>Number of entries in the dictionary determines the number of bits required for the index -- a dictionary with 25,000 words requires 15 bits to encode the index </li></ul>
  10. 10. Arithmetic Coding <ul><li>String of characters with occurrence probabilities make up a message </li></ul><ul><li>A complete message may be fragmented into multiple smaller strings </li></ul><ul><li>A codeword corresponding to each string is found separately </li></ul>
  11. 11. Summary <ul><li>Statistical encoding exploits the fact that not all symbols in the source information occur with equal probability </li></ul><ul><li>Variable length codewords are used with the shortest ones used to encode symbols that occur most frequently </li></ul><ul><li>Static coding -- text type is pre-defined and codewords are derived once and used for all subsequent transfers </li></ul><ul><li>Dynamic coding -- type of text may vary from one transfer to another and same set of codewords are generated at the transmitter and the receiver as the transfer takes place </li></ul>
  12. 12. Image and Video Compression <ul><li>Two dimensional array of pixel values </li></ul><ul><li>Spatial redundancy and temporal redundancy </li></ul><ul><li>Human eye is less sensitive to chrominance signal than to luminance signal (U and V can be coarsely coded) </li></ul><ul><li>Human eye is less sensitive to the higher spatial frequency components </li></ul><ul><li>Human eye is less sensitive to quantizing distortion at high luminance levels </li></ul>
  13. 13. JPEG Encoder <ul><li>International standards body -- Joint Photographic Experts Group </li></ul><ul><li>JPEG encoder schematic </li></ul><ul><li>Image/block preparation </li></ul><ul><li>DCT computation </li></ul><ul><li>Quantization </li></ul><ul><li>Entropy coding -- vectoring, differential encoding, run-length encoding, Huffman encoding </li></ul><ul><li>Frame building </li></ul>
  14. 14. Image/block Preparation <ul><li>Source image as 2-D matrix of pixel values </li></ul><ul><li>R, G, B format requires three matrices, one each for R, G, B quantized values </li></ul><ul><li>In Y, U, V representation, the U and V matrices can be half as small as the Y matrix </li></ul><ul><li>Source image matrix is divided into blocks of 8X8 submatrices </li></ul><ul><li>Smaller block size helps DCT computation and individual blocks are sequentially fed to the DCT which transforms each block separately </li></ul>
  15. 15. DCT Computation <ul><li>Each pixel value in the 2-D matrix is quantized using 8 bits which produces a value in the range of 0 to 255 for the intensity/luminance values and the range of -128 to + 127 for the chrominance values. All values are shifted to the range of -128 to + 127 before computing DCT </li></ul><ul><li>All 64 values in the input matrix contribute to each entry in the transformed matrix </li></ul><ul><li>The value in the location F[0,0] of the transformed matrix is called the DC coefficient and is the average of all 64 values in the matrix </li></ul><ul><li>The other 63 values are called the AC coefficients and have a frequency coefficient associated with them </li></ul><ul><li>Spatial frequency coefficients increase as we move from left to right (horizontally) or from top to bottom (vertically). Low spatial frequencies are clustered in the left top corner. </li></ul>
  16. 16. Quantization <ul><li>The human eye responds to the DC coefficient and the lower spatial frequency coefficients </li></ul><ul><li>If the magnitude of a higher frequency coefficient is below a certain threshold, the eye will not detect it </li></ul><ul><li>Set the frequency coefficients in the transformed matrix whose amplitudes are less than a defined threshold to zero (these coefficients cannot be recovered during decoding) </li></ul><ul><li>During quantization, the size of the DC and AC coefficients are reduced </li></ul><ul><li>A division operation is performed using the predefined threshold value as the divisor </li></ul>
  17. 17. Quantization Table <ul><li>Threshold values vary for each of the 64 DCT coefficients and are held in a 2-D matrix </li></ul><ul><li>Trade off between the level of compression required and the information loss that is acceptable </li></ul><ul><li>JPEG standard includes two default quantization tables -- one for the luminance coefficients and the other for use with the two sets of chrominance coefficients. Customized tables may be used </li></ul>
  18. 18. Entropy Coding <ul><li>Vectoring -- 2-D matrix of quantized DCT coefficients are represented in the form of a single-dimensional vector </li></ul><ul><li>After quantization, most of the high frequency coefficients(lower right corner) are zero. </li></ul><ul><li>To exploit the number of zeros, a zig-zag scan of the matrix is used </li></ul><ul><li>Zig-zag scan allows all the DC coefficients and lower frequency AC coefficients to be scanned first </li></ul><ul><li>DC are encoded using differential encoding and AC coefficients are encoded using run-length encoding. Huffman coding is used to encode both after that. </li></ul>
  19. 19. Differential Encoding <ul><li>DC coefficient is the largest in the transformed matrix. </li></ul><ul><li>DC coefficient varies slowly from one block to the next. </li></ul><ul><li>Only the difference in value of the DC coefficients is encoded. Number of bits required to encode is reduced. </li></ul><ul><li>The difference values are encoded in the form (SSS, value) where SSS field indicates the number of bits needed to encode the value and the value field indicates the binary form. </li></ul>
  20. 20. Run-length Encoding <ul><li>63 values of the AC coefficients </li></ul><ul><li>Long strings of zeros because of the zig-zag scan </li></ul><ul><li>Each AC coefficient encoded as a pair of values -- (skip, value), skip indicates the number of zeros in the run and value is the next non-zero coefficient </li></ul>
  21. 21. Huffman Encoding <ul><li>Long strings of binary digits replaced by shorter codewords </li></ul><ul><li>Prefix property of the huffman codewords enable decoding the encoded bitstream unambiguously </li></ul>
  22. 22. Frame Building <ul><li>Encapsulates the information relating to an encoded image </li></ul>
  23. 23. Video Compression <ul><li>Video as a sequence of pictures (or frames) </li></ul><ul><li>JPEG algorithm applied to each frame -- moving JPEG (MJPEG). Exploits only spatial redundancy. </li></ul><ul><li>High correlation between successive frames. Only small portion of each frame is involved with any motion that is taking place. </li></ul><ul><li>A combination of actual frame contents and predicted frame contents are used. </li></ul><ul><li>Motion estimation and motion compensation </li></ul>
  24. 24. Frame/Picture Types <ul><li>Interframe and intraframe coding. High compression ratios can be achieved by using both. Random access requirement of image retrieval is satisfied by pure intraframe coding. </li></ul><ul><li>I-frames are coded without reference to other frames. Serve as reference pictures for predictive-coded frames. </li></ul><ul><li>P-frames are coded using motion compensated prediction from a past I-frame or P-frame. </li></ul><ul><li>B-frames are bidirectionally predictive-coded. Highest degree of compression, but require both past and future reference pictures for motion compensation. </li></ul><ul><li>D-frames are DC-coded. Of the DCT coefficients only the DC coefficients are present. Used in interactive applications like VoD for rewind and fast-forward operations. </li></ul>
  25. 25. Picture Sequence <ul><li>I B B P B B P B B I (display order) </li></ul><ul><li>Bitstream order -- I P B B P B B P B B I </li></ul><ul><li>Prediction span, Group of Pictures (GOP) </li></ul>
  26. 26. MPEG-video Encoding <ul><li>Input frames are preprocessed (color space conversion and spatial resolution adjustment). </li></ul><ul><li>Frame types are decided for each frame/picture </li></ul><ul><li>Each picture is divided into macroblocks of 16 X 16 pixels. </li></ul><ul><li>Macroblocks are intracoded for I frames and predictive coded or intracoded for P and B frames </li></ul><ul><li>Macroblocks are divided into six blocks of 8 X 8 pixels (4 luminance and 2 chrominance) and DCT is applied to each block and transform coefficients are quantized and zig-zag scanned and variable-length coded. </li></ul>