You are on page 1of 35

Image compression

1
Outline
□ Fundamentals
□ Some basic compression methods

2
Image compression
▪ Image compression is minimizing the size in
bytes of a graphics file without degrading the
quality of the image to an unacceptable level.

▪ The reduction in file size allows more images


to be stored in a given amount of disk or
memory space.

▪ It also reduces the time required for images to


be sent over the Internet or downloaded from
Web pages.

3
Image compression..

□ The goal of data compression


■ Reduce the amount of data required to
represent a given quantity of information
■ Reduce relative data redundancy

■ n1 and n2 denote the number of information


carrying units in two data-sets that represent
the same information.
■ CR is the compression ratio.
4
Information vs Data

REDUNDANT
DATA

INFORMATION

DATA = INFORMATION + REDUNDANT DATA


5
Redundancies
□ Three basic data “redundancies” for
image compression:
■ Coding redundancy
■ Inter-pixel redundancy and
■ Psycho-visual redundancy

6
□ Coding redundancy is due to inefficiencies in
data representations.
□ Spatial and temporal redundancy
■ remove unnecessarily replicated
information in the representations of the
pixels
□ Irrelevant information
■ Remove information ignored by the
human visual system.

7
Coding redundancy
□ The gray level of an image, rk occur with
probability pr (rk).
□ The average of number bits required to
represent each pixel

□ Where
■ L= number of gray levels.
■ l( rk ) = number of bits used to represent
each value of rk.

8
Image
Compression
□Variable length coding -assign fewer bits to the more
probable gray level than less probable ones achieve data
compression

9
Interpixel redundancy

□ If a pixel value can be reasonably predicted from


its neighboring pixels the image is said to
contain interpixel redundancy.

□ Interpixel redundancy depends on the resolution


of the image
■ The higher the resolution of an image, the more
probable it is that two neighboring pixels will
depict the same object

■ The higher the frame rate in a video stream, the


more probable it is that the corresponding pixel in
the following frame will depict the same object.
10
Psychovisual redundancy

□ The human visual system does not rely on quantitative


analysis of individual pixel values when interpreting an
image.

□ In this process certain information is relatively less


important than other – this information is called
psychovisually redudant.

□ Psychovisually redundant image information can be


identified and removed – a process referred to as
quantization.

□ Quantization eliminates data and therefore results in


lossy data compression
11
Image compression models

□ A compression system consists of two structural


blocks: an encoder and a decoder
□ Encoder is made up of source encoder and a
channel encoder

12
Image compression models
□ Source encoder
■ Reduce or eliminate any coding, inter-pixel or
psychovisual redundancies in the input image
□ The corresponding source encoder-
■ mapper,
■ quantizer and
■ symbol encoder
□ Mapper
■ transforms the input data into a format designed
to reduce inter-pixel redundancies
■ Reversible process

13
Image compression models….

□ Quantizer
■ Reduce psycho-visual redundancy
■ Irreversible operation.
□ The symbol encoder
■ Creates a fixed or variable-length to represent
quantizer output and maps the output in
accordance with the code
■ A variable length code is used to represent the
mapped and quantized data set
□ Source decoder contains only two components: a
symbol decoder and inverse mapper because of
irreversible operation of quantizer

14
Image
Compression

15
Lossless compression
□ Provides limited compression capabilities - information
theory provides a mathematical framework for (and
good measures of) the levels of compression that can
be achieved

□ Principally motivated by application specifications –


data loss may be unacceptable

■ Medical imaging – diagnostic quality must be


maintained
■ Satellite imaging – image acquisition costs are
astronomical

16
Huffman coding
□ Provides a data representation with the smallest
possible number of code symbols per source symbol.

□ Source reductions
■ Create a series of source reductions by ordering
the probabilities of the symbols and then
■ combine the symbols of lowest probability to form
new symbols recursively.
■ This step is sometimes referred to as “building a
Huffman tree” and can be done statistically
□ Code assignment
□ When only two symbols remain, retrace the steps in
(1) and assign a code bit to the symbols in each step
17
Image
Compression

18
Arithmetic coding

□ Provides a data representation where the entire


symbol sequence is encoded as a single arithmetic
code word (which is represented as an interval of real
numbers between 0 and 1)

□ Arithmetic code construction is done in 3 steps


■ Subdivide the half-open interval [0,1) based on
the probabilities of the source symbols
■ For each source symbol recursively
• Narrow the interval to the sub-interval
designated by the encoded symbol
• Subdivide the new interval among the source
symbols based on probability

19
Image
Compression

20
Run-length coding

□ Provides a data representation where sequences of


symbol values of the same value are coded as “run-
lengths”
• 1D – the image is treated as a row-by-row array
of pixels
• 2D – blocks of pixels are viewed as source
symbols
□ Works well for simple, artificial images
□ Input data
2222222222266666666666666999999999999
□ Code 2,11 6,14 9,12

21
Predictive coding
□ Provides a data representation where code words
express source symbol deviations from predicted
values (usually values of neighboring pixels)
□ Predictive coding efficiently reduces interpixel
redundancies
• 1D & 2D – pixels are predicted from neighboring
pixels
• 3D – pixels are predicted between frames as well
□ Input data
222222222226666666666666699999999999999999
□ Code
200000000004000000000000030000000000000000

22
Lossy compression
□ Provides higher compression capabilities - is
usually specified in terms of application

□ Principally motivated by application


specifications –
• Distortions are tolerable.
• The observers visual system may not be able
to point these distortions

23
Transform coding
□ In transform coding a linear transform is used to
map the image data into a set of transform
coefficients.
□ The image is subdivided into smaller subimages
before the transformation computation to reduce
computational complexity
□ The goal of the transformation process is to
minimize the variance of the pixels of the
subimages as much as possible
□ Transformation coding can be
• Adaptive – each subimage is treated in an
individual manner
• Non-adaptive – all subimages are treated in the
same way

24
Transform coding

25
JPEG

Joint Photographic Experts Group

26
JPEG Encoding Process outlined
1. Color Space Transformation
2. Downsampling
3. Discrete Cosine Transform
4. Quantization
5. Entropy Coding

27
Color Space Transformation
□ Color space is transformed
□ from RGB to YCbCr

28
Downsampling
□ Cb and Cr components are
downsampled
□ Possible ratios in JPEG:
■ 4:4:4
■ 4:2:2
■ 4:2:0 (most common, reduce by factor 2
in both directions)

29
Discrete Cosine Transform

□ Transformation to
frequency domain is
done in 8×8 blocks
(matrices)
□ All values in the matrix
are first shifted down
(subtracted) by 128

30
DCT
□ DCT is applied
□ values are rounded to
integers
□ 2-D DCT transforms
the image into linear
combination of these
patterns

31
Quantization
□ Values in the transformed
matrix are divided by
corresponding values in
Quantization matrix.
□ Round (-415/16)
= Round(-25.93)
= -26

32
Entropy Coding
▪ The matrix is sequenced using zig-
zag scanning, that groups similar
frequencies together
▪ The sequence is compressed using
lossless RLE and the coded with
Huffman or Arithmetic coding.

33
Decoding Process
□ Basically the encoding done backwards
□ Reconstruct the Huffman/RLE stream to a
sequence
□ Arrange the sequence to a matrix using the
zigzag scanning backwards
□ Multiply the matrix by quantization table
□ Perform inverse DCT
□ Shift the values by +128
□ Transform back to RGB color space

34
Thank You

35

You might also like