scalar quantization - oregon state...
TRANSCRIPT
![Page 1: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/1.jpg)
Lecture 12:Lossy Image Compression and
Scalar Quantization
Thinh NguyenOregon State University
![Page 2: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/2.jpg)
Lossy Image Compression Techniques
Scalar quantization (SQ)
Vector quantization (VQ)
Discrete Cosine Transform (DCT) Compression:JPEG
Wavelet Compressions:SPIHTEBCOT
![Page 3: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/3.jpg)
Lossy Image Compression Techniques
SPIHT
(Set Partition Hierarchy Tree)
Original JPEG
32:1 compression
![Page 4: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/4.jpg)
Images and the EyeImages are meant to be viewed by the human eye.
The eye is very good at “interpolation,” that is, the eye can tolerate some distortion. So lossy compression is not necessarily bad.
![Page 5: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/5.jpg)
Distortion
![Page 6: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/6.jpg)
DistortionPeak Signal to Noise Ratio (PSNR) is the tandard way to measure fidelity.
PSNR is measured in decibels (dB):0.5 to 1 dB is said to be a perceptible difference.Decent images start at about 25-30 dB.35-40 dB might be indistinguishable from the original
![Page 7: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/7.jpg)
PSNR is not everything!
![Page 8: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/8.jpg)
Distortion vs. Compression
![Page 9: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/9.jpg)
Quantization Problem
Analog signals
sampling quantization
Digital signals
A/D converterDigital Signal processing
D/A converter
Analog signals
Real-world signals are continuous!
Signal representation in computer is discrete with finite precision!
Higher precision requires larger storage
![Page 10: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/10.jpg)
Scalar Quantization Problems
Problem 1:You’re given 16-bit integers (0-65545). Unfortunately, you only have space to store 8-bit integers (0-255).
Come up with a representation of those 16-bit integers that uses only 8 bits!
Problem 2:You have a string of those 8-bit integers that use your representation.
Recreate the 16-bit integers as best you can!
![Page 11: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/11.jpg)
Scalar Quantization
![Page 12: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/12.jpg)
Scalar Quantization Strategies
Build a codebook with a training set, then always encode and decode with that fixed codebook.
Most common use of scalar quantization.
Build a codebook for each image and transmit the codebook with the image.Training can be slow.
![Page 13: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/13.jpg)
Distortion from Scalar Quantization
![Page 14: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/14.jpg)
Uniform Quantization Example
![Page 15: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/15.jpg)
Uni. Quant. Encoder and Decoder
![Page 16: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/16.jpg)
Improve Bit Rate
![Page 17: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/17.jpg)
Example
![Page 18: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/18.jpg)
Improve Distortion
![Page 19: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/19.jpg)
Example
![Page 20: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/20.jpg)
Extreme Case
![Page 21: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/21.jpg)
Quantization Examples: Mandrill
8 bit quantization 4 bit quantization 3 bit quantization
![Page 22: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/22.jpg)
Quantization Examples: Pepper
8 bit quantization 4 bit quantization 3 bit quantization
![Page 23: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/23.jpg)
Non-uniform scalar quantization
![Page 24: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/24.jpg)
Non-uniform scalar quantizationProblem: Given M reconstruction levels, find the boundaries of these construction levels (b1,b2, … bM) and reconstruction levels (y1,y2, … yM) to minimize the distortion.
b1 b2 b3 b4b-4 b-3 b-2 b-1
y1
y2
y3
y-2
y-3
Input x
![Page 25: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/25.jpg)
Non-uniform scalar quantizationLLoyd (1957) shows that the solutions yi and bi must satisfy the following 2 conditions:
∫
∫
−
−=j
j
j
j
b
b
b
bj
dxxf
dxxxf
y
1
1
)(
)(
21 jj
j
yyb
+= +
input x offunction density y probabilit theis :)(xf
![Page 26: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/26.jpg)
Non-uniform scalar quantizationProof: Take derivatives of with respect to yi and biof MSE, setting the result to zero, and solve for yiand bi
∑ ∫=
−
−=M
i
b
bi
j
j
dxxfyxMSE1
2
1
)()(
![Page 27: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/27.jpg)
Lloyd’s AlgorithmLloyd (1957)Creates an optimized (but probably not optimal) codebook of size n.Let px be the probability of pixel value x.
Probabilities is either known or might come from a training set.Given codewords c(0),c(1),...,c(n-1) and pixel x. Let index(x) be the index of the closest code word to x.Expected distortion is
Goal of the Lloyd algorithm is to find the codewords that minimize distortion.
Lloyd finds a local minimum by an iteration process.
![Page 28: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/28.jpg)
Lloyd’s Algorithm
![Page 29: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/29.jpg)
Example
![Page 30: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/30.jpg)
Example
![Page 31: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/31.jpg)
Example
![Page 32: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/32.jpg)
Example
![Page 33: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/33.jpg)
Example
![Page 34: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/34.jpg)
Example
![Page 35: Scalar Quantization - Oregon State Universityweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring06/lossy_q… · Lossy Image Compression and Scalar Quantization Thinh Nguyen Oregon](https://reader034.vdocument.in/reader034/viewer/2022042116/5e938331bb311f0d9b154b5f/html5/thumbnails/35.jpg)
Scalar Quantization NotesUseful for analog to digital conversion.
With entropy coding, it yields good lossy compression.
Lloyd algorithm works very well in practice, but can take many iterations.
For n codewords should use about 20n sizerepresentative training set.Imagine 1024 codewords.