School of Computing Science Simon Fraser University

Slides:



Advertisements
Similar presentations
T.Sharon-A.Frank 1 Multimedia Compression Basics.
Advertisements

JPEG DCT Quantization FDCT of 8x8 blocks.
Data Compression CS 147 Minh Nguyen.
M-JPEG M-JPEG April 15, 2015 INF5063: Programming heterogeneous multi-core processors.
School of Computing Science Simon Fraser University
CSc 461/561 CSc 461/561 Multimedia Systems Part B: 1. Lossless Compression.
SWE 423: Multimedia Systems
Department of Computer Engineering University of California at Santa Cruz Data Compression (3) Hai Tao.
Computer Science 335 Data Compression.
Data Compression Basics
Image (and Video) Coding and Processing Lecture: DCT Compression and JPEG Wade Trappe Again: Thanks to Min Wu for allowing me to borrow many of her slides.
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
CMPT 365 Multimedia Systems
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
2007Theo Schouten1 Compression "lossless" : f[x,y]  { g[x,y] = Decompress ( Compress ( f[x,y] ) | “lossy” : quality measures e 2 rms = 1/MN  ( g[x,y]
CS430 © 2006 Ray S. Babcock Lossy Compression Examples JPEG MPEG JPEG MPEG.
Lossless Compression in Multimedia Data Representation Hao Jiang Computer Science Department Sept. 20, 2007.
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.
Why Compress? To reduce the volume of data to be transmitted (text, fax, images) To reduce the bandwidth required for transmission and to reduce storage.
1 Lossless Compression Multimedia Systems (Module 2) r Lesson 1: m Minimum Redundancy Coding based on Information Theory: Shannon-Fano Coding Huffman Coding.
©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.
Spring 2015 Mathematics in Management Science Binary Linear Codes Two Examples.
CSE679: MPEG r MPEG-1 r MPEG-2. MPEG r MPEG: Motion Pictures Experts Group r Standard for encoding videos/movies/motion pictures r Evolving set of standards.
Image and Video Compression
Image Compression - JPEG. Video Compression MPEG –Audio compression Lossy / perceptually lossless / lossless 3 layers Models based on speech generation.
Trevor McCasland Arch Kelley.  Goal: reduce the size of stored files and data while retaining all necessary perceptual information  Used to create an.
CM613 Multimedia storage and retrieval Lecture: Lossy Compression Slide 1 CM613 Multimedia storage and retrieval Lossy Compression D.Miller.
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.
Lab #5-6 Follow-Up: More Python; Images Images ● A signal (e.g. sound, temperature infrared sensor reading) is a single (one- dimensional) quantity that.
Klara Nahrstedt Spring 2011
Concepts of Multimedia Processing and Transmission IT 481, Lecture 5 Dennis McCaughey, Ph.D. 19 February, 2007.
Mohamed Hefeeda 1 School of Computing Science Simon Fraser University CMPT 880: Multimedia Systems Video Coding Mohamed Hefeeda.
Prof. Amr Goneid Department of Computer Science & Engineering
JPEG. The JPEG Standard JPEG is an image compression standard which was accepted as an international standard in  Developed by the Joint Photographic.
Indiana University Purdue University Fort Wayne Hongli Luo
CIS679: Multimedia Basics r Multimedia data type r Basic compression techniques.
JPEG CIS 658 Fall 2005.
An introduction to audio/video compression Dr. Malcolm Wilson.
CS Spring 2014 CS 414 – Multimedia Systems Design Lecture 10 – Compression Basics and JPEG Compression (Part 4) Klara Nahrstedt Spring 2014.
Lecture 4: Lossless Compression(1) Hongli Luo Fall 2011.
The task of compression consists of two components, an encoding algorithm that takes a file and generates a “compressed” representation (hopefully with.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
JPEG (Joint Photographic Expert Group)
JPEG Image Compression Standard Introduction Lossless and Lossy Coding Schemes JPEG Standard Details Summary.
JPEG.
Page 11/28/2016 CSE 40373/60373: Multimedia Systems Quantization  F(u, v) represents a DCT coefficient, Q(u, v) is a “quantization matrix” entry, and.
Block-based coding Multimedia Systems and Standards S2 IF Telkom University.
STATISTIC & INFORMATION THEORY (CSNB134) MODULE 11 COMPRESSION.
Introduction to JPEG m Akram Ben Ahmed
Multi-media Data compression
Image Processing Architecture, © Oleh TretiakPage 1Lecture 7 ECEC 453 Image Processing Architecture Lecture 8, February 5, 2004 JPEG: A Standard.
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.
1 Chapter 3 Text and image compression Compression principles u Source encoders and destination decoders u Lossless and lossy compression u Entropy.
JPEG Compression What is JPEG? Motivation
Data Compression.
JPEG.
Data Compression.
Data Compression CS 147 Minh Nguyen.
CMPT 365 Multimedia Systems
Presentation transcript:

School of Computing Science Simon Fraser University CMPT 820: Multimedia Systems Image Compression Mohamed Hefeeda

Compression Methods Audio, image, and video require huge storage and network bandwidth if not compressed Example: 10-min video clip (with no audio) 30 frames per sec Frame resolution = 720 pixels x 480 pixels Bits per pixel = 8 x 3 = 24 Video file size ~= 17.4 GB Bandwidth required for streaming > 240 Mb/s 2 2

Types of Compression Lossless Compression: no information is lost Run-Length Encoding (RLE) Entropy Encoding Shannon-Fano, Huffman Arithmetic Encoding Lossy Compression: some (unimportant) information is lost E.g., frequencies not heard in audio, subtle details not noticed in image  high compression ratios 3 3

Run-Length Encoding Idea: consider the following pixel values 255, 255, 255, 255, 240, 240, 240, 150, 150, 150 RLE (value, repetition): (255,4), (240, 3), (150, 2) Size of compressed string? Value: needs 8 bits (ranges from 0 to 255) Repetition: depends on the longest run in the image Assume repetition takes 8 bits for the above example  Compression ratio = (10 x 1 byte ) / (3 x 2 bytes) = 1.67 RLE used in image/video compression Usually there are rows of pixels with same color RLE may increase size in some situations! 255, 255, 240, 210 (255, 2), (240,1), (210,1)  ratio = 4/6=0.67 4 4

Entropy Encoding Entropy of information source S generating symbols is: pi : probability of symbol i appearing Entropy (as in physics) measures the degree of randomness of symbols generated by the source S always generates same specific symbol  H(S) = 0 H(S) increases as uncertainty increases, max when all symbols are equally likely to appear Shannon showed that: The minimum average number of bits needed to represent a string of symbols equals to its entropy 5 5

Entropy Encoding: Examples Ex1: image with 256 pixels, each with different color  pi = 1/256 for i = 0,1,2, …, 255  Entropy = 8 That is, average #bits to encode each color is 8 (cannot do better) Ex2: image with 256 pixels, with the following Entropy = 2.006  min avg #bits to represent a color We can achieve this by assigning different #bits (codes) to different colors (variable length encoding) Huffman and Shannon-Fano algorithms approximate this Color Freq pi Min #bits black 100 0.391 1.356 white yellow   20 0.078 3.678 orange    5 0.020 5.678 red purple    3 0.012 6.415 blue 6 6

Huffman Algorithm Two passes: Variable Length Encoding: Fewer number of bits for more frequent colors Two passes: Determine the codes for the colors Compute frequencies Build Huffman tree (bottom up) Assign codes (top down) Replace each color by its code 7 7

Huffman Algorithm: Example Image with five colors Huffman tree 8 8

Huffman Algorithm: Example (cont’d) Assigning codes top down Decoding Need frequencies (or the tree) Bits from the compressed file are matched (left=0 & right=1) from root down Note: each color needs integer number of bits, although the optimal (according Shannon) may be fractional  Arithmetic Encoding 9 9

Arithmetic Encoding Avoids the disadvantage of Huffman encoding Comes closer to the optimal Still uses statistical analysis (entropy coding) It encodes a whole string of symbols in one floating point number Each symbol is assigned a probability interval with size proportional to its frequency of occurrence The code (floating point number) of a sequence of symbols is created by successively narrowing the range between 0 and 1 for each symbol 10 10

Arithmetic Encoding: Example 100 pixels with frequencies  Consider encoding 6 pixels: W K K Y R B W: interval 0.4 – 0.65 K: interval 0 – 0.4 of the W’s interval And so on … Color Frequency Probability Interval black (K) 40/100 = 0.4 0–0.4 white (W) 25/100 = 0.25 0.4–0.65 yellow (Y) 15/100 = 0.15 0.65–0.8 red (R) 10/100 = 0.1 0.8–0.9 blue (B) 0.9–1.0 11 11

Arithmetic Encoding: Example Encoding of W K K Y R B 12 12

Arithmetic Encoding: Example Decoding: Assume final number (code) is 0.43137 Falls in W’s interval  first symbol is W Subtract low value of W’s interval and scale by its width  (0.43137 – 0.4)/0.25 = 0.12548 which is in K’s interval  second symbol is K … and so on 13 13

Arithmetic Encoding: Notes Form of entropy encoding But gives closer to optimal results (more compression) than Huffman encoding Can be done using only integer operations IBM and other companies hold patents on algorithms for arithmetic encoding Used in recent video coding standards (H.264/AVC) 14 14

JPEG Compression Divide image into 8 × 8 pixel blocks Convert image to luminance/chrominance model, e.g., YCbCr Optional; could apply same algorithm on each of the R, G, B components Apply 2d DCT Shift pixel values by -128 (makes image more centered around 0) Quantize DCT coefficients Store DC value (upper left corner) as the difference between current DC value and DC from previous block Do run-length encoding in zigzag order Do entropy encoding, e.g., Huffman Store file in standard format (header contains info for decoder, e.g., quantization tables, Huffman codes, …) 15 15

Chroma Subsampling Eye is more sensitive to changes in light (luminance) than in color (chrominance)  subsample CbCr Subsampling notation: a:b:c From 4 x 4 block: take a samples from Y; b samples from each of Cb & Cr from top row; and c samples from each of Cb & Cr from bottom row Common examples: 4:1:1; 4:2:0; 4:2:2 Ex: 4:2:0 yields a saving of (16 * 3) / (16 + 4 * 2) = 2

Subsampling and Macroblocks With subsampling (i.e., if YCbCr is used), we create 8 x 8 blocks as follows: Divide the image into 16 x 16 macroblocks  four 8 x 8 blocks for Y (no subsampling for Y) #of blocks for CbCr depends on the subsampling E.g., 4:2:0 & 4:1:1  one block for Cb & one for Cr Y Cb Cr S 16 x 16

Quantize DCT Coefficients Divide each coefficient by integer and round The main lossy operation in the whole compression algorithm Larger integers  Larger compression AND larger distortion/error High frequency coefficients are usually small  become zeros  more compression Quantization Table Each coefficient could have a different quantizer Larger quantizers for high frequency coefficients

Run-length Encoding Done in zigzag order sorts values from low-frequency to high frequency components  longer strings of 0’s (because high frequency components are usually 0) Important: Work out the complete example in [Sec 3.1, Burg09]

Summary Lossless compression: RLE, Entropy, Arithmetic Lossy compression: ignores less important info to achieve higher compression ratios Chroma subsampling: take fewer samplers from colors de-emphasize color components because eyes are more sensitive to luminance E.g., 4:2:2  4 samples Y, 2 samples CbCr each from even row, 2 samples CbCr from odd rows JPEG compress Blocks  convert to YCbCr  DCT  Quantize  zigzag RLE  Entropy coding