compressioncs6640/compression09.pdf · 2016-08-22 · compression model image 1 compress...
TRANSCRIPT
![Page 1: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/1.jpg)
Image Compression
CS 6640 School of Computing University of Utah
![Page 2: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/2.jpg)
Compression
• What – Reduce the amount of information (bits)
needed to represent image • Why
– Transmission – Storage – Preprocessing…
![Page 3: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/3.jpg)
Redundant & Irrelevant Information
• “Your wife Helen will meet you at O’Hare Airport in Chicago at 5 minutes past 6pm tomorrow night”
• Irrelevant or redudant can depend on context – Who is receiving the message?
![Page 4: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/4.jpg)
Compression Model
Image 1 compress
Save/transmit (File 2)
decompress Image 2
Image1 == Image2 -> “lossless” <- reduces redundant info
Image1 != Image2 -> “lossy” <- tries to reduce redundant & irrelevant info
Size(File1)/Size(File2) -> “compression ratio”
Save/transmit (File 1)
“channel”
![Page 5: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/5.jpg)
Redundancy
• Coding redundancy – More bits than necessary to create unique
codes • Spatial/geometric redundancy
– Correlation between pixels – Patterns in image
• Psychopysical redundancy (irrelevancy?) – Users cannot distinguish – Applies to any application (no affect on
output)
![Page 6: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/6.jpg)
Transform Coding�Standard Strategy
Image 1 Transform (mapper) Quantizer Symbol
encoder Channel
Image 2 Transform inverse
Symbol decoder Channel
• Note: can have special source or channel modules – Account for specific properties of image/
application – Account for specific properties of channel (e.g.
noise)
![Page 7: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/7.jpg)
Fundamentals • Information content of a signal -> entropy
• Lower bound on #bits need to unambiguously represent a sequence of symbols
x
Low entropy
High entropy
p(x)
![Page 8: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/8.jpg)
Strategy (optimal)
• Variable-Length Codes • Devote fewer bits to those symbols that
are most likely – More generally -> sequences of symbols
• Where do the statistics come from? – A-priori knowledge – The signal itself (send dictionary) – Ad hoc schemes
![Page 9: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/9.jpg)
Huffman Coding • Input: sumbols and probabilities • Output: variable length symbol table
– Coded/decoded one at a time • Tree
1
Symbol Pr()
A1 1/2
A2 1/4
A3 1/8
A4 1/8
1
1
0
0
0
1/4
1/2
Code
0
10
110
111
![Page 10: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/10.jpg)
Huffman Coding
1
Symbol Pr()
A2 0.4
A6 0.3
A1 0.1
A4 0.1
A3 0.06
A5 0.04
0 1
0
0 0.1
0.3
Code
1
00
011
0100
01010
01011
0.2
1
0
0.6 1
1
0
![Page 11: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/11.jpg)
Fixed Length Codes
• Dictionary with strategy to capture special structure of data
• Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary (e.g. grey levels) – As new sequences of symbols are encountered
add them to dictionary • Hope: encode frequently occuring sequences of
symbols – Greedy
– Can decompress w/out table (first occurance not replaced)
![Page 12: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/12.jpg)
LSW Compress
![Page 13: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/13.jpg)
LSW Decompress
![Page 14: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/14.jpg)
Run Length Enoding (RLE) • Good for images with few, discrete color values • Assumption: images have homogeneous regions • Strategy
– Row-major order – Encode value of “run” and it’s length – Can combine with symbol encoder
• Issues – How homogeneous is the data? – Is there enough continuity in rows?
![Page 15: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/15.jpg)
RLE For 2D • Complex -> lots of strategies • Trace contours surrounding regions • Encode contours using a incremental
scheme with a differential strategy (to improve statistics)
1 (0)
(1) (0) (0) (1)
(0) (1)
(0) (1) (0) (0) (0) (2)
(0) (0)
1 1
2 2 3 3
4 5
5 6 7 7 7 0
0 0
![Page 16: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/16.jpg)
Predictive Coding
• Take advantage of correlations • Have a simple model that predicts data
– Encode differences from prediction – Residual should be lower entropy
Prediction–encode difference
![Page 17: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/17.jpg)
Lossy Compression
• Transforms – Move to another representation where
“importance” of information is more readily discernable
– Usually reversible • Quantization
– Strategy for reducing the amount of information in the signal
– Typically not reversible (lossy)
![Page 18: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/18.jpg)
Quantization • Eliminate symbols that are too small or
not important • Find a small set of approximating
symbols (less entropy) – Grey level or “vector quantization” – Find values that minimize error – Related to “clustering” in pattern
recognition
![Page 19: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/19.jpg)
Block Transform Coding: JPEG • International standard (ISO) • Baseline algorithm with
extensions • Transform: discrete cosine
transform (DCT) – Encodes freq. Info w/out
complex #s – FT of larger, mirrored signal – Does not have other nice prop.
of FT
![Page 20: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/20.jpg)
JPEG Algorithm
• Integer grey-level image broken into 8x8 sub blocks
• Set middle (mean?) grey level to zero (subtract middle)
• DCT of sub blocks (11 bit precision) -> T(u,v)
• Rescale frequency components by Z(u,v) and round
![Page 21: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/21.jpg)
Rescaling
• Different scalling matrices possible, but recommended is:
![Page 22: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/22.jpg)
Reordering • DCT entries reordered in zig-zag fashion to
increase coherency (produce blocks of zeros)
![Page 23: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/23.jpg)
Coding
• Each sub-block is coded as a difference from previous sub-block
• Zeros are run-length encoded and nonzero elements are Huffman coded – Modified HC to allow for zeros
![Page 24: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/24.jpg)
JPEG Example�Compression Ratio ~10:1
Loss of high frequencies Block artifacts Ringing
![Page 25: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/25.jpg)
Other Transformations • Sub-band coding
– Band-pass transformations that partition the Fourier domain into pieces
– Convolve with those filters and take advantage of sparse structure
• Hopefully many values near zero (quantization)
• Wavelets – Multiscale filters – Like subband filters but typically other
properties • Eg. Orthogonal (inner between diff filters in bank is
zero)
![Page 26: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/26.jpg)
Wavelets as Hierarchical Decomposition
• Image pyramids – Represent low-frequency information at
coarser scale (less resolution)
Convolution with LP and subsampling
![Page 27: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/27.jpg)
Wavelet Example: Harr Mother wavelet Scaling function
Orthogonality
1D signal, discrete, 8 samples ->
Transformation Matrix
![Page 28: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/28.jpg)
Extending to 2D • Must take all combinations of wavelet and
scaling function at a given scale – LL, HL, LH, HH
• Typically organized in blocks, recursively – LL is futher decomposed by lower frequency
wavelets – Apply recursively to LL
HH
HL
LH
HH
HL
LH
HH HL
LH
LL
HH
HL
LH
LL
![Page 29: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/29.jpg)
Wavelet Decomposition LL HL
HH LH
![Page 30: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/30.jpg)
Wavelet Decomposition HL
HH LH
![Page 31: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/31.jpg)
Wavelet Decomposition
![Page 32: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/32.jpg)
Wavelet Compression Algorithm
• Like JPEG, but use DWT instead of DCT • Steps
– Transform – Weights (emprical) – Quantize – Entropy (lossless encoding) through RLE, VLC,
or dictionary
![Page 33: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/33.jpg)
Wavelet Compression
![Page 34: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/34.jpg)
DWT Compression Artifacts
~80:1
![Page 35: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/35.jpg)
Smarter Ways To Encode
• Embedded zero-tree wavelets (Shapiro 1993) – Zeros (threshold) at coarse level likely to be
indicative of finer level – E.g. edges – Continue through levels to hit bit quota
![Page 36: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/36.jpg)
Other Wavelets
• Harr is orthogonal, symmetric, discontinuous
• Daubechies biorthogonal wavelet – Continuous, but not symmetric – Family of wavelets with parameters – JPEG 2000 calls for “Daubechies 9/7
biorthogonal”
![Page 37: compressioncs6640/compression09.pdf · 2016-08-22 · Compression Model Image 1 compress Save/transmit (File 2) ... • Example: LZW (Lempel-Ziv-Welch) – Start with basic dictionary](https://reader033.vdocuments.site/reader033/viewer/2022060500/5f1ab055282e797e3d15a67c/html5/thumbnails/37.jpg)
Comparisons of Compression
Grgic et al., 2001