image compression
DESCRIPTION
image compression in multimediaTRANSCRIPT
![Page 1: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/1.jpg)
Image Compression (Chapter 8)
CS474/674 – Prof. Bebis
![Page 2: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/2.jpg)
Goal of Image Compression
• Digital images require huge amounts of space for storage and large bandwidths for transmission. – A 640 x 480 color image requires close to 1MB of space.
• The goal of image compression is to reduce the amount of data required to represent a digital image.– Reduce storage requirements and increase transmission rates.
![Page 3: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/3.jpg)
Approaches
• Lossless– Information preserving– Low compression ratios
• Lossy– Not information preserving– High compression ratios
• Trade-off: image quality vs compression ratio
![Page 4: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/4.jpg)
Data ≠ Information
• Data and information are not synonymous terms!
• Data is the means by which information is conveyed.
• Data compression aims to reduce the amount of data required to represent a given quantity of information while preserving as much information as possible.
![Page 5: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/5.jpg)
Data vs Information (cont’d)
• The same amount of information can be represented by various amount of data, e.g.:
Your wife, Helen, will meet you at Logan Airport in Boston at 5 minutes past 6:00 pm tomorrow night
Your wife will meet you at Logan Airport at 5 minutes past 6:00 pm tomorrow night
Helen will meet you at Logan at 6:00 pm tomorrow night
Ex1:
Ex2:
Ex3:
![Page 6: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/6.jpg)
Data Redundancy
compression
Compression ratio:
![Page 7: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/7.jpg)
Data Redundancy (cont’d)
• Relative data redundancy:
Example:
![Page 8: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/8.jpg)
Types of Data Redundancy
(1) Coding
(2) Interpixel
(3) Psychovisual
• Compression attempts to reduce one or more of these redundancy types.
![Page 9: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/9.jpg)
Coding Redundancy
• Code: a list of symbols (letters, numbers, bits etc.)
• Code word: a sequence of symbols used to represent a piece of information or an event (e.g., gray levels).
• Code word length: number of symbols in each code word
![Page 10: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/10.jpg)
Coding Redundancy (cont’d)
N x M imagerk: k-th gray level
P(rk): probability of rk
l(rk): # of bits for rk
( ) ( )x
E X xP X x Expected value:
![Page 11: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/11.jpg)
Coding Redundancy (con’d)
• l(rk) = constant length
Example:
![Page 12: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/12.jpg)
Coding Redundancy (cont’d)
• l(rk) = variable length
• Consider the probability of the gray levels:
variable length
![Page 13: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/13.jpg)
Interpixel redundancy
• Interpixel redundancy implies that any pixel value can be reasonably predicted by its neighbors (i.e., correlated).
( ) ( ) ( ) ( )f x o g x f x g x a da
autocorrelation: f(x)=g(x)
![Page 14: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/14.jpg)
Interpixel redundancy (cont’d)
• To reduce interpixel redundnacy, the data must be transformed in another format (i.e., through a transformation)– e.g., thresholding, differences between adjacent pixels, DFT
• Example:
original
thresholded
(profile – line 100)
threshold
(1+10) bits/pair
![Page 15: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/15.jpg)
Psychovisual redundancy
• The human eye does not respond with equal sensitivity to all visual information.
• It is more sensitive to the lower frequencies than to the higher frequencies in the visual spectrum.
• Idea: discard data that is perceptually insignificant!
![Page 16: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/16.jpg)
Psychovisual redundancy (cont’d)
256 gray levels 16 gray levels16 gray levels
C=8/4 = 2:1i.e., add to each pixel asmall pseudo-random numberprior to quantization
Example: quantization
![Page 17: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/17.jpg)
How do we measure information?
• What is the information content of a message/image?
• What is the minimum amount of data that is sufficient to describe completely an image without loss of information?
![Page 18: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/18.jpg)
Modeling Information
• Information generation is assumed to be a probabilistic process.
• Idea: associate information with probability!
Note: I(E)=0 when P(E)=1
A random event E with probability P(E) contains:
![Page 19: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/19.jpg)
How much information does a pixel contain?
• Suppose that gray level values are generated by a random variable, then rk contains:
units of information!
![Page 20: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/20.jpg)
• Average information content of an image:
units/pixel
1
0
( ) Pr( )L
k kk
E I r r
using
How much information does an image contain?
(assumes statistically independent random events)
Entropy
![Page 21: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/21.jpg)
• Redundancy:
Redundancy (revisited)
where:
Note: of Lavg= H, the R=0 (no redundancy)
![Page 22: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/22.jpg)
Entropy Estimation
• It is not easy to estimate H reliably!
image
![Page 23: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/23.jpg)
Entropy Estimation (cont’d)
• First order estimate of H:
![Page 24: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/24.jpg)
Estimating Entropy (cont’d)
• Second order estimate of H:– Use relative frequencies of pixel blocks :
image
![Page 25: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/25.jpg)
Estimating Entropy (cont’d)
• The first-order estimate provides only a lower-bound on the compression that can be achieved.
• Differences between higher-order estimates of entropy and the first-order estimate indicate the presence of interpixel redundancy!
Need to apply transformations!
![Page 26: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/26.jpg)
Estimating Entropy (cont’d)• For example, consider differences:
16
![Page 27: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/27.jpg)
Estimating Entropy (cont’d)
• Entropy of difference image:
• However, a better transformation could be found since:
• Better than before (i.e., H=1.81 for original image)
![Page 28: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/28.jpg)
Image Compression Model
![Page 29: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/29.jpg)
Image Compression Model (cont’d)
•
• Mapper: transforms input data in a way that facilitates reduction of interpixel redundancies.
![Page 30: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/30.jpg)
Image Compression Model (cont’d)
•
• Quantizer: reduces the accuracy of the mapper’s output in accordance with some pre-established fidelity criteria.
![Page 31: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/31.jpg)
Image Compression Model (cont’d)
•
• Symbol encoder: assigns the shortest code to the most frequently occurring output values.
![Page 32: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/32.jpg)
Image Compression Models (cont’d)
• Inverse operations are performed.
• But … quantization is irreversible in general.
![Page 33: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/33.jpg)
Fidelity Criteria
• How close is to ?
• Criteria– Subjective: based on human observers – Objective: mathematically defined criteria
![Page 34: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/34.jpg)
Subjective Fidelity Criteria
![Page 35: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/35.jpg)
Objective Fidelity Criteria
• Root mean square error (RMS)
• Mean-square signal-to-noise ratio (SNR)
![Page 36: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/36.jpg)
RMSE = 5.17 RMSE = 15.67 RMSE = 14.17
Objective Fidelity Criteria (cont’d)
![Page 37: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/37.jpg)
Lossless Compression
![Page 38: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/38.jpg)
Lossless Methods: Taxonomy
![Page 39: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/39.jpg)
Huffman Coding (coding redundancy)
• A variable-length coding technique.• Optimal code (i.e., minimizes the number of code
symbols per source symbol).
• Assumption: symbols are encoded one at a time!
![Page 40: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/40.jpg)
Huffman Coding (cont’d)
• Forward Pass1. Sort probabilities per symbol2. Combine the lowest two probabilities3. Repeat Step2 until only two probabilities
remain.
![Page 41: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/41.jpg)
Huffman Coding (cont’d)
• Backward PassAssign code symbols going backwards
![Page 42: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/42.jpg)
Huffman Coding (cont’d)
• Lavg using Huffman coding:
• Lavg assuming binary codes:
![Page 43: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/43.jpg)
Huffman Coding/Decoding
• After the code has been created, coding/decoding can be implemented using a look-up table.
• Note that decoding is done unambiguously.
![Page 44: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/44.jpg)
Arithmetic (or Range) Coding (coding redundancy)
• No assumption on encode source symbols one at a time.– Sequences of source symbols are encoded together.
– There is no one-to-one correspondence between source symbols and code words.
• Slower than Huffman coding but typically achieves better compression.
![Page 45: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/45.jpg)
Arithmetic Coding (cont’d)
• A sequence of source symbols is assigned a single arithmetic code word which corresponds to a sub-interval in [0,1].
• As the number of symbols in the message increases, the interval used to represent it becomes smaller.
• Smaller intervals require more information units (i.e., bits) to be represented.
![Page 46: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/46.jpg)
Arithmetic Coding (cont’d)
Encode message: a1 a2 a3 a3 a4
0 1
1) Assume message occupies [0, 1)
2) Subdivide [0, 1) based on the probability of αi
3) Update interval by processing source symbols
![Page 47: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/47.jpg)
Example
a1 a2 a3 a3 a4
[0.06752, 0.0688) or, 0.068
Encode
![Page 48: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/48.jpg)
Example
• The message a1 a2 a3 a3 a4 is encoded using 3 decimal digits or 3/5 = 0.6 decimal digits per source symbol.
• The entropy of this message is:
Note: finite precision arithmetic might cause problems due to truncations!
-(3 x 0.2log10(0.2)+0.4log10(0.4))=0.5786 digits/symbol
![Page 49: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/49.jpg)
1.0
0.8
0.4
0.2
0.8
0.72
0.56
0.48
0.40.0
0.72
0.688
0.624
0.592
0.592
0.5856
0.5728
0.5664a3 a3 a1 a2 a4
0.5728
0.57152
056896
0.56768
0.56 0.56 0.5664
Decode 0.572
Arithmetic Decoding
a1
a2
a3
a4
![Page 50: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/50.jpg)
LZW Coding (interpixel redundancy)
• Requires no priori knowledge of pixel probability distribution values.
• Assigns fixed length code words to variable length sequences.
• Patented Algorithm US 4,558,302
• Included in GIF and TIFF and PDF file formats
![Page 51: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/51.jpg)
LZW Coding
• A codebook (or dictionary) needs to be constructed.
• Initially, the first 256 entries of the dictionary are assigned to the gray levels 0,1,2,..,255 (i.e., assuming 8 bits/pixel)
Consider a 4x4, 8 bit image 39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126
Dictionary Location Entry
0 01 1. .255 255256 -
511 -
Initial Dictionary
![Page 52: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/52.jpg)
LZW Coding (cont’d)
39 39 126 126
39 39 126 126
39 39 126 12639 39 126 126
- Is 39 in the dictionary……..Yes - What about 39-39………….No - Then add 39-39 in entry 256
Dictionary Location Entry
0 01 1. .255 255256 -
511 -
39-39
As the encoder examines image pixels, gray level sequences (i.e., blocks) that are not in the dictionary are assigned to a new entry.
![Page 53: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/53.jpg)
Example
39 39 126 12639 39 126 12639 39 126 12639 39 126 126
Concatenated Sequence: CS = CR + P
else: (1) Output D(CR) (2) Add CS to D (3) CR=P
If CS is found: (1) No Output (2) CR=CS
(CR) (P)
CR = empty
![Page 54: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/54.jpg)
Decoding LZW
• The dictionary which was used for encoding need not be sent with the image.
• Can be built on the “fly” by the decoder as it reads the received code words.
![Page 55: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/55.jpg)
Differential Pulse Code Modulation (DPCM) Coding (interpixel redundancy)
• A predictive coding approach.
• Each pixel value (except at the boundaries) is predicted based on its neighbors (e.g., linear combination) to get a predicted image.
• The difference between the original and predicted images yields a differential or residual image.– i.e., has much less dynamic range of pixel values.
• The differential image is encoded using Huffman coding.
![Page 56: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/56.jpg)
Run-length coding (RLC) (interpixel redundancy)
• Used to reduce the size of a repeating string of characters (i.e., runs):
1 1 1 1 1 0 0 0 0 0 0 1 (1,5) (0, 6) (1, 1)
a a a b b b b b b c c (a,3) (b, 6) (c, 2)
• Encodes a run of symbols into two bytes: (symbol, count)
• Can compress any type of data but cannot achieve high compression ratios compared to other compression methods.
![Page 57: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/57.jpg)
Bit-plane coding (interpixel redundancy)
• An effective technique to reduce inter pixel redundancy is to process each bit plane individually.
(1) Decompose an image into a series of binary images.
(2) Compress each binary image (e.g., using run-length coding)
![Page 58: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/58.jpg)
Combining Huffman Coding with Run-length Coding
• Assuming that a message has been encoded using Huffman coding, additional compression can be achieved using run-length coding.
e.g., (0,1)(1,1)(0,1)(1,0)(0,2)(1,4)(0,2)
![Page 59: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/59.jpg)
Lossy Compression
• Transform the image into a domain where compression can be performed more efficiently (i.e., reduce interpixel redundancies).
~ (N/n)2 subimages
![Page 60: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/60.jpg)
Example: Fourier Transform
The magnitude of the FT decreases, as u, v increase!
K-1 K-1
K << N
![Page 61: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/61.jpg)
Transform Selection
• T(u,v) can be computed using various transformations, for example:– DFT
– DCT (Discrete Cosine Transform)
– KLT (Karhunen-Loeve Transformation)
![Page 62: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/62.jpg)
DCT
if u=0
if u>0
if v=0
if v>0
forward
inverse
![Page 63: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/63.jpg)
DCT (cont’d)
• Basis set of functions for a 4x4 image (i.e.,cosines of different frequencies).
![Page 64: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/64.jpg)
DCT (cont’d)
DFT WHT DCT
RMS error: 2.32 1.78 1.13
8 x 8 subimages
64 coefficientsper subimage
50% of the coefficientstruncated
![Page 65: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/65.jpg)
DCT (cont’d)
• DCT minimizes "blocking artifacts" (i.e., boundaries between subimages do not become very visible).
DFT
i.e., n-point periodicitygives rise todiscontinuities!
DCTi.e., 2n-point periodicityprevents discontinuities!
![Page 66: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/66.jpg)
DCT (cont’d)
• Subimage size selection:
2 x 2 subimagesoriginal 4 x 4 subimages 8 x 8 subimages
![Page 67: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/67.jpg)
JPEG Compression
• JPEG is an image compression standard which was accepted as an international standard in 1992.
• Developed by the Joint Photographic Expert Group of the ISO/IEC for coding and compression of color/gray scale images.
• Yields acceptable compression in the 10:1 range.
• A scheme for video compression based on JPEG called Motion JPEG (MJPEG) exists
![Page 68: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/68.jpg)
JPEG Compression (cont’d)
• JPEG uses DCT for handling interpixel redundancy.
• Modes of operation:(1) Sequential DCT-based encoding
(2) Progressive DCT-based encoding
(3) Lossless encoding
(4) Hierarchical encoding
![Page 69: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/69.jpg)
JPEG Compression (Sequential DCT-based encoding)
Entropyencoder
Entropydecoder
![Page 70: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/70.jpg)
JPEG Steps
1. Divide the image into 8x8 subimages;
For each subimage do:
2. Shift the gray-levels in the range [-128, 127] - DCT requires range be centered around 0
3. Apply DCT (i.e., 64 coefficients)
1 DC coefficient: F(0,0)
63 AC coefficients: F(u,v)
![Page 71: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/71.jpg)
Example
(i.e., non-centeredspectrum)
![Page 72: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/72.jpg)
JPEG Steps
4. Quantize the coefficients (i.e., reduce the amplitude of coefficients that do not contribute a lot).
Q(u,v): quantization table
![Page 73: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/73.jpg)
Example
• Quantization Table Q[i][j]
![Page 74: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/74.jpg)
Example (cont’d)
Quantization
![Page 75: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/75.jpg)
JPEG Steps (cont’d)
5. Order the coefficients using zig-zag ordering- Place non-zero coefficients first
- Create long runs of zeros (i.e., good for run-length encoding)
![Page 76: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/76.jpg)
Example
![Page 77: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/77.jpg)
JPEG Steps (cont’d)
6. Form intermediate symbol sequence and encode coefficients:
6.2 AC coefficients: variable length coding
6.1 DC coefficients: predictive encoding
![Page 78: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/78.jpg)
Intermediate Coding
symbol_1 (SIZE) symbol_2 (AMPLITUDE)
DC
DC (6) (61)
AC (0,2) (-3)
end of block
symbol_1 (RUN-LENGTH, SIZE) symbol_2 (AMPLITUDE)
SIZE: # bits for encoding amplitudeRUN-LENGTH: run of zeros
![Page 79: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/79.jpg)
DC/AC Symbol Encoding
• DC encoding
• AC encoding
symbol_1 symbol_2 (SIZE) (AMPLITUDE)
If RUN-LENGTH > 15, use symbol (15,0) , i.e., RUN-LENGTH=16
0 0 0 0 0 0 476 (6,9)(476)
[-2048, 2047]=
predictivecoding:
= [-210, 210-1] 1 ≤SIZE≤10
[-211, 211-1]1 ≤SIZE≤11
![Page 80: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/80.jpg)
Entropy Encoding (e.g, variable length)
![Page 81: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/81.jpg)
Entropy Encoding (e.g, Huffman) Symbol_1(Variable Length Code (VLC))
Symbol_2(Variable Length Integer (VLI))
(1,4)(12) (111110110 1100)VLC VLI
![Page 82: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/82.jpg)
Effect of “Quality”
90 (58k bytes)50 (21k bytes)10 (8k bytes)
best quality,
lowest compression
worst quality,
highest compression
![Page 83: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/83.jpg)
Effect of “Quality” (cont’d)
![Page 84: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/84.jpg)
Example 1: homogeneous 8 x 8 block
![Page 85: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/85.jpg)
Example 1 (cont’d)
Quantized De-quantized
![Page 86: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/86.jpg)
Example 1 (cont’d)
Reconstructed Error
![Page 87: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/87.jpg)
Example 2: less homogeneous 8 x 8 block
![Page 88: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/88.jpg)
Example 2 (cont’d)
Quantized De-quantized
![Page 89: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/89.jpg)
Example 2 (cont’d)
Reconstructed – spatial Error
![Page 90: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/90.jpg)
JPEG for Color Images
• Could apply JPEG on R/G/B components .
• It is more efficient to describe a color in terms of its luminance and chrominance content separately, to enable more efficient processing.– YUV
• Chrominance can be subsampled due to human vision insensitivity
![Page 91: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/91.jpg)
JPEG for Color Images
• Luminance: Received brightness of the light (proportional to the total energy in the visible band).
• Chrominance: Describe the perceived color tone of the light (depends on the wavelength composition of light – Hue: Specify the color tone (i.e., depends on the peak
wavelength of the light).
– Saturation: Describe how pure the color is (i.e., depends on the spread or bandwidth of the light spectrum).
![Page 92: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/92.jpg)
YUV Color Space
• YUV color space– Y is the components of luminance
– Cb and Cr are the components of chrominance
– The values in the YUV coordinate are related to the values in the RGB coordinate by:
0.299 0.587 0.114 0
0.169 0.334 0.500 128
0.500 0.419 0.081 128
Y R
Cb G
Cr B
![Page 93: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/93.jpg)
JPEG for Color Images
Image
RG
B
YVU colorcoordinate
ChrominanceDownsampling(4:2:2 or 4:2:0)
8 X 8 FDCT
Quantizer
QuantizationTable
zigzag
DifferentialCoding
HuffmanEncoding
HuffmanEncoding
Bit-stream
DecodedImage
RG
B
ChrominanceUpsampling
(4:2:2 or 4:2:0)
8 X 8IDCT
YVU colorcoordinate
Dequantizer
QuantizationTable
De-zigzag
De-DC coding
HuffmanDecoding
HuffmanDecoding
Bit-stream
Encoder
Decoder
![Page 94: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/94.jpg)
JPEG Modes
• JPEG supports several different modes– Sequential Mode– Progressive Mode– Hierarchical Mode– Lossless Mode
• Sequential is the default mode– Each image component is encoded in a single left-to-right,
top-to-bottom scan.– This is the mode we have been describing.
![Page 95: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/95.jpg)
Progressive JPEG
• The image is encoded in multiple scans, in order to produce a quick, rough decoded image when transmission time is long.
Sequential
Progressive
![Page 96: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/96.jpg)
Progressive JPEG (cont’d)
• Send DCT coefficients in multiple scans: (1) Progressive spectral selection algorithm
(2) Progressive successive approximation algorithm
(3) Hybrid progressive algorithm
![Page 97: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/97.jpg)
Progressive JPEG (cont’d)
(1) Progressive spectral selection algorithm– Group DCT coefficients into several spectral bands
– Send low-frequency DCT coefficients first
– Send higher-frequency DCT coefficients next
![Page 98: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/98.jpg)
Progressive JPEG (cont’d)
(2) Progressive successive approximation algorithm– Send all DCT coefficients but with lower precision.
– Refine DCT coefficients in later scans.
![Page 99: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/99.jpg)
Progressive JPEG (cont’d)
(3) Hybrid progressive algorithm– Combines spectral selection and successive approximation.
![Page 100: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/100.jpg)
Results using spectral selection
![Page 101: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/101.jpg)
Results using successive approximation
![Page 102: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/102.jpg)
Example using successive approximationafter 0.9s after 1.6s
after 3.6s after 7.0s
![Page 103: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/103.jpg)
Hierarchical JPEG
• Hierarchical mode encodes the image at several different resolutions.
• Image is transmitted in multiple passes with increased resolution at each pass.
![Page 104: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/104.jpg)
Hierarchical JPEG (cont’d)
N x N
N/2 x N/2
N/4 x N/4
f
f2
f4
![Page 105: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/105.jpg)
Hierarchical JPEG (cont’d)
![Page 106: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/106.jpg)
Hierarchical JPEG (cont’d)
![Page 107: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/107.jpg)
Lossless JPEG
• Uses predictive coding (see later)
![Page 108: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/108.jpg)
Lossy Methods: Taxonomy
![Page 109: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/109.jpg)
Lossless Differential Pulse Code Modulation (DPCM) Coding
• Each pixel value (except at the boundaries) is predicted based on certain neighbors (e.g., linear combination) to get a predicted image.
• The difference between the original and predicted images yields a differential or residual image.
• Encode differential image using Huffman coding.
xm
Predictor
Entropy Encoder
pm
dm
![Page 110: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/110.jpg)
Lossy Differential Pulse Code Modulation (DPCM) Coding
• Similar to lossless DPCM except that (i) it uses quantization and (ii) the pixels are predicted from the “reconstructed” values of certain neighbors.
![Page 111: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/111.jpg)
Block Truncation Coding
• Divide image in non-overlapping blocks of pixels.
• Derive a bitmap (0/1) for each block using thresholding.– e.g., use mean pixel value in each block as threshold.
• For each group of 1s and 0s, determine reconstruction value– e.g., average of corresponding pixel values in original block.
![Page 112: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/112.jpg)
Subband Coding
• Analyze image to produce components containing frequencies in well defined bands (i.e., subbands)– e.g., use wavelet transform.
• Optimize quantization/coding in each subband.
![Page 113: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/113.jpg)
Vector Quantization
• Develop a dictionary of fixed-size vectors (i.e., code vectors), usually blocks of pixel values.
• Partition image in non-overlapping blocks (i.e., image vectors).
• Encode each image vector by the index of its closest code vector.
![Page 114: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/114.jpg)
Fractal Coding
• What is a “fractal”?– A rough or fragmented geometric shape that can be split into
parts, each of which is (at least approximately) a reduced-size copy of the whole.
Idea: store images as collections of transformations!
![Page 115: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/115.jpg)
Fractal Coding (cont’d)
Generated by 4 affinetransformations!
![Page 116: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/116.jpg)
Fractal Coding (cont’d)
• Decompose image into segments (i.e., using standard segmentations techniques based on edges, color, texture, etc.) and look them up in a library of IFS codes.
• Best suited for textures and natural images.
![Page 117: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/117.jpg)
Fingerprint Compression
• An image coding standard for digitized fingerprints, developed and maintained by: – FBI
– Los Alamos National Lab (LANL)
– National Institute for Standards and Technology (NIST).
• The standard employs a discrete wavelet transform-based algorithm (Wavelet/Scalar Quantization or WSQ).
![Page 118: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/118.jpg)
Memory Requirements
• FBI is digitizing fingerprints at 500 dots per inch with 8 bits of grayscale resolution.
• A single fingerprint card turns into about 10 MB of data!
A sample fingerprint image
768 x 768 pixels =589,824 bytes
![Page 119: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/119.jpg)
Preserving Fingerprint Details
The "white" spots in the middle of the black ridges are sweat pores
They’re admissible points of identification in court, as are the little black flesh ‘‘islands’’ in the grooves between the ridges
These details are just a couple pixels wide!
![Page 120: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/120.jpg)
What compression scheme should be used?
• Better use a lossless method to preserve every pixel perfectly.
• Unfortunately, in practice lossless methods haven’t done better than 2:1 on fingerprints!
• Would JPEG work well for fingerprint compression?
![Page 121: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/121.jpg)
Results using JPEG compressionfile size 45853 bytescompression ratio: 12.9
The fine details are pretty much history, and the whole image has this artificial ‘‘blocky’’ pattern superimposed on it.
The blocking artifacts affect the performance of manual or automated systems!
![Page 122: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/122.jpg)
Results using WSQ compressionfile size 45621 bytescompression ratio: 12.9
The fine details are preserved better than they are with JPEG.
NO blocking artifacts!
![Page 123: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/123.jpg)
WSQ Algorithm
![Page 124: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/124.jpg)
Varying compression ratio
• FBI’s target bit rate is around 0.75 bits per pixel (bpp)– i.e., corresponds to a target compression ratio of 10.7
(assuming 8-bit images)
• This target bit rate is set via a ‘‘knob’’ on the WSQ algorithm.– i.e., similar to the "quality" parameter in many JPEG
implementations.
• Fingerprints coded with WSQ at a target of 0.75 bpp will actually come in around 15:1
![Page 125: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/125.jpg)
Varying compression ratio (cont’d)
Original image 768 x 768 pixels (589824 bytes)
![Page 126: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/126.jpg)
Varying compression ratio (cont’d) 0.9 bpp compression
WSQ image, file size 47619 bytes, compression ratio 12.4
JPEG image, file size 49658 bytes, compression ratio 11.9
![Page 127: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/127.jpg)
Varying compression ratio (cont’d)0.75 bpp compression
WSQ image, file size 39270 bytes compression ratio 15.0
JPEG image, file size 40780 bytes, compression ratio 14.5
![Page 128: Image compression](https://reader037.vdocument.in/reader037/viewer/2022102621/54b4d8274a79593d368b46bc/html5/thumbnails/128.jpg)
Varying compression ratio (cont’d)0.6 bpp compression
WSQ image, file size 30987 bytes, compression ratio 19.0
JPEG image, file size 30081 bytes, compression ratio 19.6