Image and video compression University of the Philippines - Diliman August 2006 Diane Lingrand
[email protected] http://www.polytech.unice.fr/~lingrand 1
Today's menu • • • • •
Ideas for image compression Huffman coding LZW coding Discrete transforms: Fourier, cosinus Well known formats : – GIF, PNG, JPEG
2
Why do we need to compress an image ? • Storage : – hard drive – digital camera, PDA, …
• Transmission – Internet – Radio waves
3
Objectives • • • •
Rapidity of compression / decompression Robustness of decompression Compression ratio Quantity of informations : – with or without loss of data
• Quality :
– the best, according to our visual abilities – sufficient for detection of informations
4
Error measurement • Difficult and complex problem • MSE = Mean Square Error • PSNR = Peak Signal Noise Ratio
MSE
MSE 5
Huffman coding: descending phase values ni n1 probabilities 0.3
n2
n3
n4
n5
n6
n7
n8
0.18
0.15 0.10 0.10 0.09 0.05 0.03
1st step : from m=8 to m=7 n7 and n8 have the smallest probabilities : we group them in one element n7,8 of probability 0.08 ... last step : there is only one element left of probability 1 6
Huffman coding: ascending phase 01
values ni n1 probabilities 0.3
11
n2
001
n3
100
n4
101
n5
0000 00010 00011
n6
n7
n8
0.18 0.15 0.10 0.10 0.09 0.05 0.03 0 0.08 1 0 0.20 1 1 1
0.32
0.38
0
1
0.17
1
0
0
0.62
1
0
0 1
order of reading 7
Huffman coding • without Huffman coding – sum of : p(ni) * 3 bits
• with Huffman coding – sum of : p(ni) * li
• In our example : 3 bits versus 2.79 bits image (640*480) : 64512 bits=8kB
8
LZW or Lempel-Ziv Welch • Used by : – gif format (color images using 8 bits) – tiff (not always) – .Z files (compress) – .gzip or .gz files (gnu zip)
• copyrighted by Compuserve and Unisys
9
LZW • Compression without loss • Good for images with large uniform areas • Algorithm: splits the set of pixels into words and gives a code to each word • Consider pixels as a 1D array (no vertical redundancy)
10
LZW : algorithm • Splitting the string of pixels into the longest strings • Construction of a table : – we begin with pixels alone – then, we consider strings of pixels, longer and longer
• The code for a string does not depend on the string's length
11
Example of LZW coding ABRACADABRACADA... w errors of prediction – Coding and transmission of motion vectors and errors data 46
MPEG 4 and 7 • for multimedia applications – hybrid coding of both natural and synthetic video – interactive modes allowing an user to interact with the contents – compatibility with low BP canals – robustness to noise – copyright protection – possibility to search for informations in the video
47
MPEG 4 and 7 (suite) • MPEG 4 :
– object oriented coding => we need segmentation
• MPEG 7 :
– normalization of the way to describe the content of a video (text criterions, visuals, sounds, …) – does not normalized the extraction of information or the search engine
48
Bibliography • http://www.data-compression.com • http://jpeg2000.epfl.ch/.
• Digital Video and HDTV (algorithms and interfaces), Charles Poynton. Morgan Kaufmann Publishers, Elsevier, 2003.
49