Image Coding and Compression

Slides:



Advertisements
Similar presentations
JPEG Compresses real images Standard set by the Joint Photographic Experts Group in 1991.
Advertisements

15 Data Compression Foundations of Computer Science ã Cengage Learning.
Data Compression CS 147 Minh Nguyen.
Image Compression. Data and information Data is not the same thing as information. Data is the means with which information is expressed. The amount of.
Data Compression Michael J. Watts
Chapter 7 End-to-End Data
SWE 423: Multimedia Systems
JPEG.
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
JPEG Still Image Data Compression Standard
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
CS430 © 2006 Ray S. Babcock Lossy Compression Examples JPEG MPEG JPEG MPEG.
5. 1 JPEG “ JPEG ” is Joint Photographic Experts Group. compresses pictures which don't have sharp changes e.g. landscape pictures. May lose some of the.
©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression.
Roger Cheng (JPEG slides courtesy of Brian Bailey) Spring 2007
1 JPEG Compression CSC361/661 Burg/Wong. 2 Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg.
Image Compression JPEG. Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg and can be embedded.
Trevor McCasland Arch Kelley.  Goal: reduce the size of stored files and data while retaining all necessary perceptual information  Used to create an.
Chapter 2 Source Coding (part 2)
Introduction to JPEG Alireza Shafaei ( ) Fall 2005.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 8 – JPEG Compression (Part 3) Klara Nahrstedt Spring 2012.
1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.
: Chapter 12: Image Compression 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Klara Nahrstedt Spring 2011
Image Processing and Computer Vision: 91. Image and Video Coding Compressing data to a smaller volume without losing (too much) information.
Multimedia Data DCT Image Compression
Indiana University Purdue University Fort Wayne Hongli Luo
Image Compression (Chapter 8) CSC 446 Lecturer: Nada ALZaben.
1 Image Formats. 2 Color representation An image = a collection of picture elements (pixels) Each pixel has a “color” Different types of pixels Binary.
An introduction to audio/video compression Dr. Malcolm Wilson.
Chapter 17 Image Compression 17.1 Introduction Redundant and irrelevant information  “Your wife, Helen, will meet you at Logan Airport in Boston.
Huffman Code and Data Decomposition Pranav Shah CS157B.
CS Spring 2014 CS 414 – Multimedia Systems Design Lecture 10 – Compression Basics and JPEG Compression (Part 4) Klara Nahrstedt Spring 2014.
Digital Image Processing Lecture 21: Lossy Compression Prof. Charlene Tsai.
The JPEG Standard J. D. Huang Graduate Institute of Communication Engineering National Taiwan University, Taipei, Taiwan, ROC.
The task of compression consists of two components, an encoding algorithm that takes a file and generates a “compressed” representation (hopefully with.
Digital Image Processing Lecture 22: Image Compression
JPEG.
STATISTIC & INFORMATION THEORY (CSNB134) MODULE 11 COMPRESSION.
Chapter 8 Lossy Compression Algorithms. Fundamentals of Multimedia, Chapter Introduction Lossless compression algorithms do not deliver compression.
Introduction to JPEG m Akram Ben Ahmed
JPEG. Introduction JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components.
By Dr. Hadi AL Saadi Lossy Compression. Source coding is based on changing of the original image content. Also called semantic-based coding High compression.
An introduction to audio/video compression Prepared by :: Bhatt shivani ( )
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM M ULTIMEDIA OF D ATA C OMPRESSION Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny.
Submitted To-: Submitted By-: Mrs.Sushma Rani (HOD) Aashish Kr. Goyal (IT-7th) Deepak Soni (IT-8 th )
Data Compression Michael J. Watts
JPEG Compression What is JPEG? Motivation
IMAGE PROCESSING IMAGE COMPRESSION
Digital Image Processing Lecture 20: Image Compression May 16, 2005
IMAGE COMPRESSION.
Data Compression.
Algorithms in the Real World
Digital Image Processing Lecture 21: Lossy Compression May 18, 2005
Digital Image Processing Lecture 21: Lossy Compression
Discrete Cosine Transform
JPEG.
Data Compression.
Huffman Coding, Arithmetic Coding, and JBIG2
Data Compression CS 147 Minh Nguyen.
Image Processing, Leture #16
JPEG Still Image Data Compression Standard
Image Compression Techniques
Image Compression Purposes Requirements Types
The JPEG Standard.
15 Data Compression Foundations of Computer Science ã Cengage Learning.
© 2010 Cengage Learning Engineering. All Rights Reserved.
15 Data Compression Foundations of Computer Science ã Cengage Learning.
Presentation transcript:

Image Coding and Compression Introduction to Digital Image Processing with MATLAB® Asia Edition McAndrew‧Wang‧Tseng Chapter 14: Image Coding and Compression © 2010 Cengage Learning Engineering. All Rights Reserved.

14.1 Lossless and Lossy Compression It is thus important for both reasons of storage and file transfer to make these file sizes smaller, if possible It will be necessary to distinguish between two different classes of compression methods: Lossless compression, where all the information is retained Lossy compression, where some information is lost © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.403

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.2 Huffman Coding The average number of bits per pixel can be calculated easily as the expected value (in a probabilistic sense): © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.404

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.2 Huffman Coding Determine the probabilities of each gray value in the image Form a binary tree by adding probabilities two at a time, always taking the two lowest available values Now assign 0 and 1 arbitrarily to each branch of the tree from its apex Read the codes from the top down © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.404

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.1 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.405

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.2 Huffman Coding © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.405

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.2 Huffman Coding We can evaluate the average number of bits per pixel as an expected value Huffman codes are uniquely decodable © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.406

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding Run-length encoding (RLE) is based on a simple idea: to encode strings of 0s and 1s by the number of repetitions in each string Encode each line separately starting with the number of 0s (binary image) © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.407

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding Encode each row as a list of pairs of numbers, the first number in each pair giving the starting position of a run of 1s and the second number its length Grayscale images can be encoded by breaking them up into their bit planes © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.407

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding Each plane can then be encoded separately using our chosen implementation of RLE © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.407

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding However, small changes of gray value may cause significant changes in bits To overcome this difficulty, we may encode the gray values with their binary Gray codes A Gray code is an ordering of all binary strings of a given length so that there is only one bit change between one string and the next © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.408

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding 4-bit gray codes Binary bit plane Gray codes © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.408

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding 14.3.1 Run-length Encoding in MATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.409

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.3 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.410

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding We can reduce the size of the output by storing it using the data type uint16 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.410

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.3 Run-length Encoding © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.411

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm Lossy compression trades some acceptable data loss for greater rates of compression The algorithm developed by the Joint Photographic Experts Group (JPEG) has become one of the most popular It uses transform coding, where the coding is done not on the pixel values themselves, but on a transform © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.411

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm discrete cosine transform (DCT) In the JPEG algorithm it is applied only to 8 × 8 blocks If f(j, k) is one such block, then the forward (2-D) DCT is defined as The corresponding inverse DCT as © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.412

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm where C(w) is defined as The DCT has a number of properties that make it particularly suitable for compression: It is real-valued, so there is no need to manipulate complex numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.412

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm It has a high information-packing ability because it packs large amounts of information into a small number of coefficients It can be implemented very efficiently in hardware Like the FFT, there is a “fast” version of the transform that maximizes efficiency The basis values are independent of the data [7] © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.412

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.412

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.4 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.414

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm The JPEG baseline compression scheme is applied as follows: The image is divided into 8 × 8 blocks, with each block transformed and compressed separately For a given block, the values are shifted by subtracting 128 from each value The DCT is applied to this shifted block The DCT values are normalized by dividing by a normalization Matrix Q. It is this normalization that provides the compression by making most of the elements of the block zero © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.413

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm This matrix is formed into a vector by reading off all nonzero values from the top left in a zigzag fashion: The first coefficients of each vector are encoded by listing the difference between each value and the values from the previous block. This helps keep all values (except for the first) small These values are then compressed using RLE All other values (known as the AC coefficients) are compressed using a Huffman coding © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.414

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm To decompress, the steps above are applied in reverse The Huffman encoding and RLE can be decoded with no loss of information The vector is read back into an 8 × 8 matrix The matrix is multiplied by the normalization matrix The inverse DCT is applied to the result The result is shifted back by 128 to obtain the original image block The normalization matrix © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.415

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.415

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.416

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm The normalization matrix © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.416

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm Where EOB signifies the end of the block. By this stage we have reduced an 8 × 8 block to a vector of length 21, containing only small values To uncompress © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.417

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.417

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm It can be seen that these values are very close to the values in the original block. The differences between original and reconstructed values are The algorithm works best on regions of low frequency; in such cases the original block can be reconstructed with only very small errors © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.418

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.5 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.419

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.6 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.420

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.7 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.421

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.8 Suppose we take our extra parameter n to be 2. This has the effect of doubling each value in the normalization matrix, thus should set more of the DCT values to 0: © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.421

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.421

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.9 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.422

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.10 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.423

© 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 14.11~14.13 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.423

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm We have seen how changing the compression rate may affect the output. The JPEG algorithm, however, is particularly designed for storage The output vector is further encoded using Huffman coding DC (first value) k contains all elements x whose absolute value satisfies © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.424

© 2010 Cengage Learning Engineering. All Rights Reserved. 14.4 The JPEG Algorithm e.g. © 2010 Cengage Learning Engineering. All Rights Reserved. Ch14-p.425