Download Khalid Sayhood Introduction to Data Compression and more Study notes Data Compression in PDF only on Docsity!
T H I R D E D I T I O N
Introduction to
Data Compression
T H I R D E D I T I O N
Introduction to
Data Compression
Khalid Sayood
University of Nebraska
AMSTERDAM •^ BOSTON •^ HEIDELBERG •^ LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Morgan Kaufmann is an imprint of Elsevier
Senior Acquisitions Editor Rick Adams Publishing Services Manager Simon Crump Assistant Editor Rachel Roumeliotis Cover Design Cate Barr Composition Integra Software Services Pvt. Ltd. Copyeditor Jessika Bella Mura Proofreader Jacqui Brownstein Indexer Northwind Editorial Sevices Interior printer Maple Vail Book Manufacturing Group Cover printer Phoenix Color
Morgan Kaufmann Publishers is an imprint of Elsevier. 500 Sansome Street, Suite 400, San Francisco, CA 94111
This book is printed on acid-free paper.
©2006 by Elsevier Inc. All rights reserved.
Designations used by companies to distinguish their products are often claimed as trademarks or registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—electronic, mechanical, photocopying, scanning, or otherwise—without prior written permission of the publisher.
Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: [email protected]. You may also complete your request on-line via the Elsevier homepage (http://elsevier.com) by selecting “Customer Support” and then “Obtaining Permissions.”
Library of Congress Cataloging-in-Publication Data Sayood, Khalid. Introduction to data compression / Khalid Sayood.—3rd ed. p. cm. Includes bibliographical references and index. ISBN-13: 978-0-12-620862- ISBN-10: 0-12-620862-X
- Data compression (Telecommunication) 2. Coding theory. I. Title TK5102.92.S39 2005 005.74′^ 6—dc 2005052759
ISBN 13: 978-0-12-620862- ISBN 10: 0-12-620862-X
For information on all Morgan Kaufmann publications, visit our Web site at www.mkp.com or www.books.elsevier.com
Printed in the United States of America 05 06 07 08 09 5 4 3 2 1
Working together to grow libraries in developing countries www.elsevier.com | www.bookaid.org | www.sabre.org
Contents
C O N T E N T S xv
- 1 Introduction Preface xvii
- 1.1 Compression Techniques
- 1.1.1 Lossless Compression
- 1.1.2 Lossy Compression
- 1.1.3 Measures of Performance
- 1.2 Modeling and Coding
- 1.3 Summary
- 1.4 Projects and Problems
- 2 Mathematical Preliminaries for Lossless Compression
- 2.1 Overview
- 2.2 A Brief Introduction to Information Theory
- 2.2.1 Derivation of Average Information
- 2.3 Models
- 2.3.1 Physical Models
- 2.3.2 Probability Models
- 2.3.3 Markov Models
- 2.3.4 Composite Source Model
- 2.4 Coding
- 2.4.1 Uniquely Decodable Codes
- 2.4.2 Prefix Codes
- 2.4.3 The Kraft-McMillan Inequality
- 2.5 Algorithmic Information Theory
- 2.6 Minimum Description Length Principle
- 2.7 Summary
- 2.8 Projects and Problems
- 3 Huffman Coding
- 3.1 Overview
- 3.2 The Huffman Coding Algorithm
- 3.2.1 Minimum Variance Huffman Codes
- 3.2.2 Optimality of Huffman Codes
- 3.2.3 Length of Huffman Codes
- 3.2.4 Extended Huffman Codes
- 3.3 Nonbinary Huffman Codes viii C O N T E N T S
- 3.4 Adaptive Huffman Coding
- 3.4.1 Update Procedure
- 3.4.2 Encoding Procedure
- 3.4.3 Decoding Procedure
- 3.5 Golomb Codes
- 3.6 Rice Codes
- 3.6.1 CCSDS Recommendation for Lossless Compression
- 3.7 Tunstall Codes
- 3.8 Applications of Huffman Coding
- 3.8.1 Lossless Image Compression
- 3.8.2 Text Compression
- 3.8.3 Audio Compression
- 3.9 Summary
- 3.10 Projects and Problems
- 4 Arithmetic Coding
- 4.1 Overview
- 4.2 Introduction
- 4.3 Coding a Sequence
- 4.3.1 Generating a Tag
- 4.3.2 Deciphering the Tag
- 4.4 Generating a Binary Code
- 4.4.1 Uniqueness and Efficiency of the Arithmetic Code
- 4.4.2 Algorithm Implementation
- 4.4.3 Integer Implementation
- 4.5 Comparison of Huffman and Arithmetic Coding
- 4.6 Adaptive Arithmetic Coding
- 4.7 Applications
- 4.8 Summary
- 4.9 Projects and Problems
- 5 Dictionary Techniques
- 5.1 Overview
- 5.2 Introduction
- 5.3 Static Dictionary
- 5.4 Adaptive Dictionary
- 5.4.1 The LZ77 Approach
- 5.4.2 The LZ78 Approach
- 5.5 Applications
- 5.5.1 File Compression—UNIX compress
- 5.5.2 Image Compression—The Graphics Interchange Format (GIF)
- 5.5.3 Image Compression—Portable Network Graphics (PNG)
- 5.5.4 Compression over Modems—V.42 bis
- 5.6 Summary C O N T E N T S ix
- 5.7 Projects and Problems
- 6 Context-Based Compression
- 6.1 Overview
- 6.2 Introduction
- 6.3 Prediction with Partial Match (ppm)
- 6.3.1 The Basic Algorithm
- 6.3.2 The Escape Symbol
- 6.3.3 Length of Context
- 6.3.4 The Exclusion Principle
- 6.4 The Burrows-Wheeler Transform
- 6.4.1 Move-to-Front Coding
- 6.5 Associative Coder of Buyanovsky (ACB)
- 6.6 Dynamic Markov Compression
- 6.7 Summary
- 6.8 Projects and Problems
- 7 Lossless Image Compression
- 7.1 Overview
- 7.2 Introduction
- 7.2.1 The Old JPEG Standard
- 7.3 CALIC
- 7.4 JPEG-LS
- 7.5 Multiresolution Approaches
- 7.5.1 Progressive Image Transmission
- 7.6 Facsimile Encoding
- 7.6.1 Run-Length Coding
- 7.6.2 CCITT Group 3 and 4—Recommendations T.4 and T.6
- 7.6.3 JBIG
- 7.6.4 JBIG2—T.88
- 7.7 MRC—T.44
- 7.8 Summary
- 7.9 Projects and Problems
- 8 Mathematical Preliminaries for Lossy Coding
- 8.1 Overview
- 8.2 Introduction
- 8.3 Distortion Criteria
- 8.3.1 The Human Visual System
- 8.3.2 Auditory Perception
- 8.4 Information Theory Revisited
- 8.4.1 Conditional Entropy
- 8.4.2 Average Mutual Information
- 8.4.3 Differential Entropy
- 8.5 Rate Distortion Theory x C O N T E N T S
- 8.6 Models
- 8.6.1 Probability Models
- 8.6.2 Linear System Models
- 8.6.3 Physical Models
- 8.7 Summary
- 8.8 Projects and Problems
- 9 Scalar Quantization
- 9.1 Overview
- 9.2 Introduction
- 9.3 The Quantization Problem
- 9.4 Uniform Quantizer
- 9.5 Adaptive Quantization
- 9.5.1 Forward Adaptive Quantization
- 9.5.2 Backward Adaptive Quantization
- 9.6 Nonuniform Quantization
- 9.6.1 pdf-Optimized Quantization
- 9.6.2 Companded Quantization
- 9.7 Entropy-Coded Quantization
- 9.7.1 Entropy Coding of Lloyd-Max Quantizer Outputs
- 9.7.2 Entropy-Constrained Quantization
- 9.7.3 High-Rate Optimum Quantization
- 9.8 Summary
- 9.9 Projects and Problems
- 10 Vector Quantization
- 10.1 Overview
- 10.2 Introduction
- 10.3 Advantages of Vector Quantization over Scalar Quantization
- 10.4 The Linde-Buzo-Gray Algorithm
- 10.4.1 Initializing the LBG Algorithm
- 10.4.2 The Empty Cell Problem
- 10.4.3 Use of LBG for Image Compression
- 10.5 Tree-Structured Vector Quantizers
- 10.5.1 Design of Tree-Structured Vector Quantizers
- 10.5.2 Pruned Tree-Structured Vector Quantizers
- 10.6 Structured Vector Quantizers
- 10.6.1 Pyramid Vector Quantization
- 10.6.2 Polar and Spherical Vector Quantizers
- 10.6.3 Lattice Vector Quantizers
- 10.7 Variations on the Theme
- 10.7.1 Gain-Shape Vector Quantization
- 10.7.2 Mean-Removed Vector Quantization
- 10.7.3 Classified Vector Quantization C O N T E N T S xi
- 10.7.4 Multistage Vector Quantization
- 10.7.5 Adaptive Vector Quantization
- 10.8 Trellis-Coded Quantization
- 10.9 Summary
- 10.10 Projects and Problems
- 11 Differential Encoding
- 11.1 Overview
- 11.2 Introduction
- 11.3 The Basic Algorithm
- 11.4 Prediction in DPCM
- 11.5 Adaptive DPCM
- 11.5.1 Adaptive Quantization in DPCM
- 11.5.2 Adaptive Prediction in DPCM
- 11.6 Delta Modulation
- 11.6.1 Constant Factor Adaptive Delta Modulation (CFDM)
- 11.6.2 Continuously Variable Slope Delta Modulation
- 11.7 Speech Coding
- 11.8 Image Coding
- 11.9 Summary
- 11.10 Projects and Problems
- 12 Mathematical Preliminaries for Transforms, Subbands, and Wavelets
- 12.1 Overview
- 12.2 Introduction
- 12.3 Vector Spaces
- 12.3.1 Dot or Inner Product
- 12.3.2 Vector Space
- 12.3.3 Subspace
- 12.3.4 Basis
- 12.3.5 Inner Product—Formal Definition
- 12.3.6 Orthogonal and Orthonormal Sets
- 12.4 Fourier Series
- 12.5 Fourier Transform
- 12.5.1 Parseval’s Theorem
- 12.5.2 Modulation Property
- 12.5.3 Convolution Theorem
- 12.6 Linear Systems
- 12.6.1 Time Invariance
- 12.6.2 Transfer Function
- 12.6.3 Impulse Response
- 12.6.4 Filter
- 12.7 Sampling xii C O N T E N T S
- 12.7.1 Ideal Sampling—Frequency Domain View
- 12.7.2 Ideal Sampling—Time Domain View
- 12.8 Discrete Fourier Transform
- 12.9 Z-Transform
- 12.9.1 Tabular Method
- 12.9.2 Partial Fraction Expansion
- 12.9.3 Long Division
- 12.9.4 Z-Transform Properties
- 12.9.5 Discrete Convolution
- 12.10 Summary
- 12.11 Projects and Problems
- 13 Transform Coding
- 13.1 Overview
- 13.2 Introduction
- 13.3 The Transform
- 13.4 Transforms of Interest
- 13.4.1 Karhunen-Loéve Transform
- 13.4.2 Discrete Cosine Transform
- 13.4.3 Discrete Sine Transform
- 13.4.4 Discrete Walsh-Hadamard Transform
- 13.5 Quantization and Coding of Transform Coefficients
- 13.6 Application to Image Compression—JPEG
- 13.6.1 The Transform
- 13.6.2 Quantization
- 13.6.3 Coding
- 13.7 Application to Audio Compression—the MDCT
- 13.8 Summary
- 13.9 Projects and Problems
- 14 Subband Coding
- 14.1 Overview
- 14.2 Introduction
- 14.3 Filters
- 14.3.1 Some Filters Used in Subband Coding
- 14.4 The Basic Subband Coding Algorithm
- 14.4.1 Analysis
- 14.4.2 Quantization and Coding
- 14.4.3 Synthesis
- 14.5 Design of Filter Banks
- 14.5.1 Downsampling
- 14.5.2 Upsampling
- 14.6 Perfect Reconstruction Using Two-Channel Filter Banks
- 14.6.1 Two-Channel PR Quadrature Mirror Filters
- 14.6.2 Power Symmetric FIR Filters
- 14.7 M-Band QMF Filter Banks C O N T E N T S xiii
- 14.8 The Polyphase Decomposition
- 14.9 Bit Allocation
- 14.10 Application to Speech Coding—G.722
- 14.11 Application to Audio Coding—MPEG Audio
- 14.12 Application to Image Compression
- 14.12.1 Decomposing an Image
- 14.12.2 Coding the Subbands
- 14.13 Summary
- 14.14 Projects and Problems
- 15 Wavelet-Based Compression
- 15.1 Overview
- 15.2 Introduction
- 15.3 Wavelets
- 15.4 Multiresolution Analysis and the Scaling Function
- 15.5 Implementation Using Filters
- 15.5.1 Scaling and Wavelet Coefficients
- 15.5.2 Families of Wavelets
- 15.6 Image Compression
- 15.7 Embedded Zerotree Coder
- 15.8 Set Partitioning in Hierarchical Trees
- 15.9 JPEG
- 15.10 Summary
- 15.11 Projects and Problems
- 16 Audio Coding
- 16.1 Overview
- 16.2 Introduction
- 16.2.1 Spectral Masking
- 16.2.2 Temporal Masking
- 16.2.3 Psychoacoustic Model
- 16.3 MPEG Audio Coding
- 16.3.1 Layer I Coding
- 16.3.2 Layer II Coding
- 16.3.3 Layer III Coding—mp3
- 16.4 MPEG Advanced Audio Coding
- 16.4.1 MPEG-2 AAC
- 16.4.2 MPEG-4 AAC
- 16.5 Dolby AC3 (Dolby Digital)
- 16.6 Other Standards
- 16.7 Summary
- 17 Analysis/Synthesis and Analysis by Synthesis Schemes xiv C O N T E N T S
- 17.1 Overview
- 17.2 Introduction
- 17.3 Speech Compression
- 17.3.1 The Channel Vocoder
- 17.3.2 The Linear Predictive Coder (Government Standard LPC-10)
- 17.3.3 Code Excited Linear Predicton (CELP)
- 17.3.4 Sinusoidal Coders
- 17.3.5 Mixed Excitation Linear Prediction (MELP)
- 17.4 Wideband Speech Compression—ITU-T G.722.2
- 17.5 Image Compression
- 17.5.1 Fractal Compression
- 17.6 Summary
- 17.7 Projects and Problems
- 18 Video Compression
- 18.1 Overview
- 18.2 Introduction
- 18.3 Motion Compensation
- 18.4 Video Signal Representation
- 18.5 ITU-T Recommendation H.261
- 18.5.1 Motion Compensation
- 18.5.2 The Loop Filter
- 18.5.3 The Transform
- 18.5.4 Quantization and Coding
- 18.5.5 Rate Control
- 18.6 Model-Based Coding
- 18.7 Asymmetric Applications
- 18.8 The MPEG-1 Video Standard
- 18.9 The MPEG-2 Video Standard—H.262
- 18.9.1 The Grand Alliance HDTV Proposal
- 18.10 ITU-T Recommendation H.263
- 18.10.1 Unrestricted Motion Vector Mode
- 18.10.2 Syntax-Based Arithmetic Coding Mode
- 18.10.3 Advanced Prediction Mode
- 18.10.4 PB-frames and Improved PB-frames Mode
- 18.10.5 Advanced Intra Coding Mode
- 18.10.6 Deblocking Filter Mode
- 18.10.7 Reference Picture Selection Mode
- 18.10.8 Temporal, SNR, and Spatial Scalability Mode
- 18.10.9 Reference Picture Resampling
- 18.10.10 Reduced-Resolution Update Mode
- 18.10.11 Alternative Inter VLC Mode
- 18.10.12 Modified Quantization Mode
- 18.10.13 Enhanced Reference Picture Selection Mode
- Coding 18.11 ITU-T Recommendation H.264, MPEG-4 Part 10, Advanced Video
- 18.11.1 Motion-Compensated Prediction
- 18.11.2 The Transform
- 18.11.3 Intra Prediction
- 18.11.4 Quantization
- 18.11.5 Coding
- 18.12 MPEG-4 Part
- 18.13 Packet Video
- 18.14 ATM Networks
- 18.14.1 Compression Issues in ATM Networks
- 18.14.2 Compression Algorithms for Packet Video
- 18.15 Summary
- 18.16 Projects and Problems
- A Probability and Random Processes
- A.1 Probability
- A.1.1 Frequency of Occurrence
- A.1.2 A Measure of Belief
- A.1.3 The Axiomatic Approach
- A.2 Random Variables
- A.3 Distribution Functions
- A.4 Expectation
- A.4.1 Mean
- A.4.2 Second Moment
- A.4.3 Variance
- A.5 Types of Distribution
- A.5.1 Uniform Distribution
- A.5.2 Gaussian Distribution
- A.5.3 Laplacian Distribution
- A.5.4 Gamma Distribution
- A.6 Stochastic Process
- A.7 Projects and Problems
- B A Brief Review of Matrix Concepts
- B.1 A Matrix
- B.2 Matrix Operations
- C The Root Lattices
- Bibliography
- Index
xviii P R E F A C E
C o u r s e U s e
The impetus for writing this book came from the need for a self-contained book that could be used at the senior/graduate level for a course in data compression in either electrical engineering, computer engineering, or computer science departments. There are problems and project ideas after most of the chapters. A solutions manual is available from the publisher. Also at http://sensin.unl.edu/idc/index.html we provide links to various course homepages, which can be a valuable source of project ideas and support material. The material in this book is too much for a one semester course. However, with judicious use of the starred sections, this book can be tailored to fit a number of compression courses that emphasize various aspects of compression. If the course emphasis is on lossless compression, the instructor could cover most of the sections in the first seven chapters. Then, to give a taste of lossy compression, the instructor could cover Sections 1–5 of Chapter 9, followed by Chapter 13 and its description of JPEG, and Chapter 18, which describes video compression approaches used in multimedia communications. If the class interest is more attuned to audio compression, then instead of Chapters 13 and 18, the instructor could cover Chapters 14 and 16. If the latter option is taken, depending on the background of the students in the class, Chapter 12 may be assigned as background reading. If the emphasis is to be on lossy compression, the instructor could cover Chapter 2, the first two sections of Chapter 3, Sections 4 and 6 of Chapter 4 (with a cursory overview of Sections 2 and 3), Chapter 8, selected parts of Chapter 9, and Chapter 10 through 15. At this point depending on the time available and the interests of the instructor and the students portions of the remaining three chapters can be covered. I have always found it useful to assign a term project in which the students can follow their own interests as a means of covering material that is not covered in class but is of interest to the student.
A p p r o a c h
In this book, we cover both lossless and lossy compression techniques with applications to image, speech, text, audio, and video compression. The various lossless and lossy coding techniques are introduced with just enough theory to tie things together. The necessary theory is introduced just before we need it. Therefore, there are three mathematical prelim- inaries chapters. In each of these chapters, we present the mathematical material needed to understand and appreciate the techniques that follow. Although this book is an introductory text, the word introduction may have a different meaning for different audiences. We have tried to accommodate the needs of different audiences by taking a dual-track approach. Wherever we felt there was material that could enhance the understanding of the subject being discussed but could still be skipped without seriously hindering your understanding of the technique, we marked those sections with a star (). If you are primarily interested in understanding how the various techniques function, especially if you are using this book for self-study, we recommend you skip the starred sections, at least in a first reading. Readers who require a slightly more theoretical approach should use the starred sections. Except for the starred sections, we have tried to keep the mathematics to a minimum.
P R E F A C E xix
L e a r n i n g f r o m T h i s B o o k
I have found that it is easier for me to understand things if I can see examples. Therefore, I have relied heavily on examples to explain concepts. You may find it useful to spend more time with the examples if you have difficulty with some of the concepts. Compression is still largely an art and to gain proficiency in an art we need to get a “feel” for the process. We have included software implementations for most of the techniques discussed in this book, along with a large number of data sets. The software and data sets can be obtained from ftp://ftp.mkp.com/pub/Sayood/. The programs are written in C and have been tested on a number of platforms. The programs should run under most flavors of UNIX machines and, with some slight modifications, under other operating systems as well. More detailed information is contained in the README file in the pub/Sayood directory. You are strongly encouraged to use and modify these programs to work with your favorite data in order to understand some of the issues involved in compression. A useful and achievable goal should be the development of your own compression package by the time you have worked through this book. This would also be a good way to learn the trade-offs involved in different approaches. We have tried to give comparisons of techniques wherever possible; however, different types of data have their own idiosyncrasies. The best way to know which scheme to use in any given situation is to try them.
C o n t e n t a n d O r g a n i z a t i o n
The organization of the chapters is as follows: We introduce the mathematical preliminaries necessary for understanding lossless compression in Chapter 2; Chapters 3 and 4 are devoted to coding algorithms, including Huffman coding, arithmetic coding, Golomb-Rice codes, and Tunstall codes. Chapters 5 and 6 describe many of the popular lossless compression schemes along with their applications. The schemes include LZW, ppm, BWT, and DMC, among others. In Chapter 7 we describe a number of lossless image compression algorithms and their applications in a number of international standards. The standards include the JBIG standards and various facsimile standards. Chapter 8 is devoted to providing the mathematical preliminaries for lossy compression. Quantization is at the heart of most lossy compression schemes. Chapters 9 and 10 are devoted to the study of quantization. Chapter 9 deals with scalar quantization, and Chapter 10 deals with vector quantization. Chapter 11 deals with differential encoding techniques, in particular differential pulse code modulation (DPCM) and delta modulation. Included in this chapter is a discussion of the CCITT G.726 standard. Chapter 12 is our third mathematical preliminaries chapter. The goal of this chapter is to provide the mathematical foundation necessary to understand some aspects of the transform, subband, and wavelet-based techniques that are described in the next three chapters. As in the case of the previous mathematical preliminaries chapters, not all material covered is necessary for everyone. We describe the JPEG standard in Chapter 13, the CCITT G. international standard in Chapter 14, and EZW, SPIHT, and JPEG 2000 in Chapter 15. Chapter 16 is devoted to audio compression. We describe the various MPEG audio compression schemes in this chapter including the scheme popularly known as mp3.