0% found this document useful (0 votes)
68 views32 pages

Lec6 - Scalar Abnd Vector Quantization

The document discusses scalar and vector quantization techniques for lossy image compression. Scalar quantization maps an input value to a finite number of output values, reducing precision. Vector quantization divides the data stream into blocks called vectors and finds the best matching pattern from a predefined codebook to send instead of the vector. The design of the quantizer impacts the compression ratio and loss incurred. Compression is achieved by reducing the number of bits needed to represent each pixel through quantization.

Uploaded by

Ali Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views32 pages

Lec6 - Scalar Abnd Vector Quantization

The document discusses scalar and vector quantization techniques for lossy image compression. Scalar quantization maps an input value to a finite number of output values, reducing precision. Vector quantization divides the data stream into blocks called vectors and finds the best matching pattern from a predefined codebook to send instead of the vector. The design of the quantizer impacts the compression ratio and loss incurred. Compression is achieved by reducing the number of bits needed to represent each pixel through quantization.

Uploaded by

Ali Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

CS 411 : Data Compression

Lecture 6

Scalar and Vector


Quantization
Lossy Image Compression Techniques

Scalar quantization (SQ)


Vector quantization (VQ)
Discrete Cosine Transform (DCT)
Compression:
 JPEG
Wavelet Compressions
Quantization

 Definition:
 Quantization: a process of representing a large –
possibly infinite – set of values with a much smaller set.
 Scalar quantization: a mapping of an input value x into
a finite number of output values, y:
Q: x y

 One of the simplest and most general idea in


lossy compression.
Scalar Quantization

Many of the fundamental ideas of


quantization and compression are easily
introduced in the simple context of scalar
quantization.
An example: any real number x can be
rounded off to the nearest integer, say
q(x) = round(x)
Maps the real line R (a continuous space)
into a discrete space.
Quantizer

 The design of the quantizer has a significant impact


on the amount of compression obtained and loss
incurred in a lossy compression scheme.
 Quantizer: encoder mapping and decode mapping.
 Encoder mapping
 – The encoder divides the range of source into a
number of intervals
– Each interval is represented by a distinct codeword
 Decoder mapping
– For each received codeword, the decoder
generates a reconstruct value
Components of Quantization

1. Encoder mapping: Divides the range of values


that the source generates into a number of
intervals. Each interval is then mapped to a
codeword. It is a many-to-one irreversible
mapping. The code word only identifies the
interval, not the original value. If the source or
sample value comes from a analog source, it is
called a A/D converter.
Mapping of a 3-bit Encoder

Codes

000 001 010 011 100 101 110 111

-3.0 -2.0 -1.0 0 1.0 2.0 3.0 input


Mapping of a 3-bit D/A Converter

Input Codes Output


000 -3.5
001 -2.5
010 -1.5
011 -0.5
100 0.5
101 1.5
110 2.5
111 3.5
Components of a Quantizer

2. Decoder: Given the code word, the decoder


gives a an estimated value that the source might
have generated. Usually, it is the midpoint of the
interval but a more accurate estimate will
depend on the distribution of the values in the
interval. In estimating the value, the decoder
might generate some errors.
Quantization
 Why? -- To reduce number of bits per sample
F’(u,v) = round(F(u,v)/q(u,v))
 Example: 101101 = 45 (6 bits).
Truncate to 4 bits: 1011 = 11. (Compare 11 x 4 =44 against 45)
Truncate to 3 bits: 101 = 5. (Compare 8 x 5 =40 against 45)
Note, that the more bits we truncate the more precision we lose
 Quantization error is the main source of the Lossy Compression.
 Uniform Quantization:
 q(u,v) is a constant.
 Non-uniform Quantization -- Quantization Tables
 Eye is most sensitive to low frequencies (upper left corner in
frequency matrix), less sensitive to high frequencies (lower right
corner)
 Custom quantization tables can be put in image/scan header.
 JPEG Standard defines two default quantization tables, one each for
luminance and chrominance.
10
Scalar Quantization

 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!
Uniform Quantization
Uniform Quantizer

Zero is one of the output levels Zero is not one of the output levels
M is odd M is even
Scalar Quantization

 Build a codebook with a training set, then


always encode and decode with that fixed
codebook.
 Build a codebook for each image and
transmit the codebook with the image.
Uniform Scalar Quantization Example
Uniform Scalar Quantization Example
Uniform Scalar Quantization Example 1
Non-Uniform Scalar Quantization Example 2
Image Compression

Original 8bits/pixel 3bits/pixel


Image Compression

2bits/pixel 1bit/pixel
Vector Quantization

 The data stream is divided to blocks called vectors.


 Table, called code-book
contains a set of patterns
may be predefined or dynamically constructed.
 Find best matching pattern in the table.
 Send table entry number instead of vector.
Principle of Vector Quantization
Original Code-book Compressed
data data stream
stream Pattern 0
Vector 0 of data stream k
...
Vector 1 of data stream 0
Pattern j
...
... ...
...
... Pattern k
i
... ...
Vector n of data stream ...
Pattern P
Vector Quantization with Error Transmission

Original Code-book Compressed


data data stream
stream
Pattern 0
k Er0
Vector 0 of data stream ...
0 Er1
Vector 1 of data stream Pattern j ... ...
... ... ... ...
... Pattern k i Eri
... ...
Vector n of data stream ...
Pattern P
Vector Quantization

Quantization is a mapping of a large set of


values to a smaller set of values.
Vector Quantization
Vector Quantization
Vector Quantization
Vector Quantization
Vector Quantization
Compression Formula

 Amount of compression:
 Codebook size is K, input vector of dimension L
 Inorder to inform the decoder of which code
vector is selected, we need to use log 2 K  bits.
 E.g. need 8 bits to represent 256 code vectors.
 Rate: each code vector contains the log 2 K  / L
reconstruction value of L source output samples,
the number of bits per sample would be:
.
 Sample: a scalar value in vector.
 K: level of vector quantizer.
Vector Quantization Example

 The original image has 256 gray scale is


600*600 pixels. The image is divided into
blocks each of size 4*4 pixels. The codebook
which will be used to reconstruct the image
consists of 32 vectors (32 blocks each of size
4*4)
Vector Quantization Example
 Labels size= number of labels * number of bits per label= 22500 *
5=112500 bits = 14063 Bytes
 Codebook storage size = number of vectors * vector size *
number of bits per pixel= 32*(4*4)*8=4096 bits = 512 bytes
 Total compressed image size= label size + code book storage
size= 112500+4096=116596 nbits = 14575 bytes
 Original image size = 600*600*8 = 2880000 bits = 36000bytes
 Compression ratio = original/compressed = 36000 / 14575= 24.7 :
1

 When label size is much greater than codebook storage size , codebook
storage size can be neglected during compression ratio calculations
 Note: codebook storage size is independent on image size , number of
labels depends on image size
 Labels size= number of labels * number of bits per label= 22500 *
5=112500 bits = 14063 Bytes
 Codebook storage size = number of vectors * vector size * number of bits
per pixel= 32*(4*4)*8=4096 bits = 512 bytes
 Total compressed image size= label size = 112500 bits = 14063 bytes
 Original image size = 600*600*8 = 2880000 bits = 36000bytes
 Compression ratio =original/compressed=360000/14063= 25.59 :
1

You might also like