Vous êtes sur la page 1sur 4

Compression (contd)

Compression (contd) Interpixel Redundancy

Interpixel Redundancy Compression (contd)


CS 450: Introduction to Digital Signal and Image Processing The basis of interpixel redundancy is Bryan Morse BYU Computer Science repetition prediction

Compression (contd) Interpixel Redundancy Repetition

Compression (contd) Interpixel Redundancy Repetition

Run-Length Encoding
Encode sequences of identical symbols as (symbol,count) pairs. Can use xed-size counts or special prexes to indicate the number of bits for the count
Fixed: can reduce compression if either too large or too small Variable: overhead for the prexes

Lempel-Ziv-Welch

Basic idea: encode longest possible previously-seen sequence Coding stream is mixture of symbols and back-pointers Better yet:
Keep a codebook of previously-seen sequences Store codebook index instead of backwards pointers.

Can extend to multiple dimensions


Encode difference from the previous line (hopefully long runs of 0s) Encode using lengths or markers from previous line

Used in most common text compression algorithms, zip, and the GIF image standard.

Useful for binary signals and black-and-white images. 2-D RLE is used in the CCITT fax standard.
Compression (contd) Interpixel Redundancy Repetition Compression (contd) Interpixel Redundancy Repetition

Lempel-Ziv-Welch

Example: Lempel-Ziv

codebook = all single symbols sequence = empty while (get(symbol)) if sequence + symbol is in codebook sequence += symbol else output(code for sequence) add sequence + symbol to codebook sequence = symbol

Mary had a little lamb, little lamb, little lamb, Mary had a little lamb, its fleece was white as snow.

Compression (contd) Interpixel Redundancy Prediction

Compression (contd) Interpixel Redundancy Prediction

Predictive Coding

Predictive Coding
Key: Sender and receiver use the same predictive model. Sender Make prediction (no peeking!) Send the residual (difference) Receiver Make prediction Add the residual to get the correct value

Use one set of symbols/pixels to predict another. Predictors:


Next pixel is like the last one Next scanline is like the last one Next frame was like the last one Next pixel is the average of the already-known neighbors

The error from the prediction (residual) hopefully has smaller entropy than the original signal. The information used to make the prediction is the context.

Lossless: entropy code the residual Lossy: quantize the residual

Compression (contd) Interpixel Redundancy Prediction

Compression (contd) Interpixel Redundancy Prediction

Simple Predictive Audio Compression: Delta Modulation

Delta Modulation

Basic Algorithm:
Prediction: next signal value is the same as the last. Residual is the difference (delta) from the previous one. Residual is encoded in a smaller number of bits than the original.

Often used in audio systems (phones). Problem: limited-range delta can cause under/overshoot.

Compression (contd) Interpixel Redundancy Prediction

Compression (contd) Interpixel Redundancy Prediction

Predictive Image Coding


Predict next pixel based on neighbors that have been already seen

Predictive Image Coding

Simplest predictor: average of the four neighbors Can use larger context Can quantize (lossy) or entropy code (lossless) the residual Used in DPCM and the lossless part of the JPEG standard. Newer algorithms (CALOC, LOCO-I) use multiple contexts and smarter predictors.

Compression (contd) Interpixel Redundancy Prediction

Compression (contd) Perceptual Redundancy

Residual: Entropy Coding / Nonuniform Quantization


The residual values should be very small, so Use fewer bits for smaller values (entropy coding), or Use ner quantization (less loss) for smaller values

Perceptual Redundancy
Eye is less sensitive to Color High Frequencies So, Allocate more bits/samples to intensity than chromaticity. Allocate more bits to low frequencies than to high frequencies Can play similar tricks with the ear and varying sensitivity to different frequencies (e.g., the psychoacoustic model plays a key role in MP3).

Compression (contd) Perceptual Redundancy Block Transform Coding

Compression (contd) Perceptual Redundancy Block Transform Coding

Block Transform Coding


Use a transform to convert from spatial domain to another (e.g., a frequency-based one) Win #1: many transforms pack the information into parts of the domain better than spatial representations Win #2: Quantize coefcients according to perception (e.g., quantize high frequencies more coarsely than low ones) Problem: artifacts caused by imperfect approximation in one place get spread across the entire image Solution: independently transform and quantize blocks of the image: block transform encoding

Transform Coding: General Structure

Compression (contd) Perceptual Redundancy Block Transform Coding

Compression (contd) Perceptual Redundancy Block Transform Coding

Transform Coding
There are many other transforms besides the Fourier Transform, all with the same structure: Forward transform (general form): T (u, v ) =
M N XX x=0 y=0

Transform Coding
Other basis sets:

Walsh-Hadamard
f (x, y ) g(x, y , u, v )

Cosine

Inverse transform (general form): f (x, y) =


M N XX u=0 v =0

T (u, v ) h(x, y , u, v )

Most of the time, g(x, y , u, v ) = h(x, y , u, v ) (possible normalized, or complex conjugates)

Compression (contd) Perceptual Redundancy Block Transform Coding

Compression (contd) Perceptual Redundancy Block Transform Coding

Discrete Cosine Transform

Discrete Cosine Transform


How can we get away with cosines and no sines? Assumes alternating periodicity instead of periodicity

g(x, y, u, v ) = h(x, y , u, v ) = (u) (v ) cos where (u) = (2x + 1)u (2y + 1)v cos 2N 2N

1 N 2 N

if u = 0 otherwise

Compression (contd) Example: JPEG

Compression (contd) Progressive Encoding

Joint Photographic Experts Group (JPEG)


Intensity/Chromaticity Convert to YCrCb color model and downsample the chromaticity components Energy compaction, convert to frequency representation Takes advantage of redundancy in the block averages Many high frequencies become zero! Changes from 2-D to 1-D and puts similar frequencies together Collapses long runs of zeroes To more efciently encode the RLE sequences

Progressive Methods
Progressive methods allow viewing of the image while downloading: Interlaced GIF:
Send every 8 scanlines, then every 4, then 2, then all Interpolate intermediate lines until they get there

8 x 8 block DCT Predictively encode DC coefcients Quantize AC coefcients Zig-zag ordering Run-length encoding Entropy encode whats left

Progressive JPEG:
Send DC coefcients rst Then send all lowest-frequency AC coefcients Then send successively higher AC coefcients

Compression (contd) Other Approaches

Other Compression Methods


Wavelets:
Similar in principle to block-transform-based methods. Greater compression/delity by exploiting both spatial and frequency information.

Fractals:
Blocks of the image are represented as rotated, translated, and rescaled copies of other blocks. Probably the highest claimed compression rates. Useful in some applications; very lossy in others. Some people are researching hybrid methods based on fractal compression.

Vous aimerez peut-être aussi