0% found this document useful (0 votes)
44 views

3.2. Image Compression (Part 1)

This document discusses image compression techniques. It begins by describing common image file formats like JPEG, PNG, and GIF. It then covers resampling techniques such as nearest neighbor, linear, bilinear, and cubic interpolation used to resize images. The document also introduces image compression concepts like lossy and lossless compression. It explains techniques used in lossy compression including transform coding, quantization, and entropy encoding. Scalar quantization is described as a process that maps a range of input values to a smaller set of discrete values.

Uploaded by

Reach
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

3.2. Image Compression (Part 1)

This document discusses image compression techniques. It begins by describing common image file formats like JPEG, PNG, and GIF. It then covers resampling techniques such as nearest neighbor, linear, bilinear, and cubic interpolation used to resize images. The document also introduces image compression concepts like lossy and lossless compression. It explains techniques used in lossy compression including transform coding, quantization, and entropy encoding. Scalar quantization is described as a process that maps a range of input values to a smaller set of discrete values.

Uploaded by

Reach
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

បណ្ឌិត្យសភាបច្ចេកវទ្យាឌ

ិ ជី ថ
ី លកម្ពុជា
Cambodia Academy of Digital and Technology

III. Image Compression (Part 1)

Lecturer: Cheat Morokot


1- Image File Formats
• Images have been developed on various platforms and used
different formats or standards.
• Today's most widely used image formats include:
 GIF (Graphics Interchange Format)
 JPEG (Joint Photographic Experts Group standard for
compressing still images)
 Animated GIF (Animated Graphics Interchange Format)
 BMP (Windows Bitmap format)
 XBM (X window Bitmap format)
 EPS (Encapsulated PostScript file format)
2
1- Image File Formats
 PNG (Portable Network Graphics)
 PSD (Adobe Photoshop's native file format)
 STN (MediaBin's proprietary STING file format)
 TIFF (Tagged Image File Format)
 TGA (TARGA bitmap graphics file format).

• Most of these image file formats are in fact compressed, for


example, JPEG, PNG, BMP and GIF.
 JPEG offers great mainly lossy compression. It supports
progression and hierarchical mode, and Huffman coding.
3
1- Image File Formats
 PNG supports up to 48 bits per pixel for colour images. It
applies LZW compression algorithms and is widely used for the
Internet application.
 BMP is the native image format in the Microsoft Windows
operating systems. Colour depth can be 1, 4, 8, 16, 24 or 32
bits. BMP supports simple run-length compression for 4 and 8
bits per pixel.
 GIF was the first universally accepted image format but ended
due to legal problems. LZW compression methods support GIF.

4
2- Resampling Technique
• Resampling is the mathematical technique used to create a new
version of the image with a different width and/or height in pixels.
• Increasing the size of an image is called up-sampling; reducing its
size is called down-sampling.
• Techniques for resampling:
 Nearest neighbor interpolation
 Linear interpolation
 Cubic interpolation
 Bilinear interpolation
 Bicubic interpolation, etc
5
2- Resampling Technique

6
2.1- Nearest Neighbor Technique
• Assign the value of the nearest neighbor to the value of the new
point.

7
2.1- Nearest Neighbor Technique
• Ex: Supposed we have a 3x3 image and we want to enlarge it to a
6x6 image

1 2 3

1 2 3
6 5 4
6 5 4

7 0 3
7 0 3

8
2.2- Linear Interpolation
• Weighting the values of the 2 neighboring points to the value of
the new point.

9
2.2- Linear Interpolation
• Linear equation:

𝑦 − 𝑦0 𝑦1 − 𝑦0
=
𝑥 − 𝑥0 𝑥1 − 𝑥0

• We get solution:
𝑦1 − 𝑦0
𝑦 = 𝑦0 + (𝑥 − 𝑥0 )
𝑥1 − 𝑥0
Or
𝑥1 − 𝑥 𝑥 − 𝑥0
𝑦= 𝑦0 + 𝑦1
𝑥1 − 𝑥0 𝑥1 − 𝑥0 10
2.3- Bilinear Interpolation
• Bilinear interpolation is an extension of linear interpolation for
interpolating functions of two variables on a rectilinear 2D grid.
• Suppose that we want to find the value of
unknown function f at the point (x, y). And
we know the value of f at Q11 = (x1, y1), Q12 =
(x1, y2), Q21 = (x2, y1), and Q22 = (x2, y2).
1. We first do linear interpolation in the x-direction:
𝑥2 − 𝑥 𝑥 − 𝑥1
𝑓(𝑥, 𝑦1 ) = 𝑓(𝑄11 ) + 𝑓(𝑄21 )
𝑥2 − 𝑥1 𝑥2 − 𝑥1
𝑥2 − 𝑥 𝑥 − 𝑥1
𝑓(𝑥, 𝑦2 ) = 𝑓(𝑄12 ) + 𝑓(𝑄22 )
𝑥2 − 𝑥1 𝑥2 − 𝑥1 11
2.3- Bilinear Interpolation
2. We proceed by interpolating in the y-direction to obtain:
𝑦2 − 𝑦 𝑦 − 𝑦1
𝑓(𝑥, 𝑦) = 𝑓(𝑥, 𝑦1 ) + 𝑓(𝑥, 𝑦2 )
𝑦2 − 𝑦1 𝑦2 − 𝑦1
𝑦2 − 𝑦 𝑥2 − 𝑥 𝑥 − 𝑥1 𝑦 − 𝑦1 𝑥2 − 𝑥 𝑥 − 𝑥1
= ( 𝑓(𝑄11 ) + 𝑓(𝑄21 )) + ( 𝑓(𝑄12 ) + 𝑓(𝑄22 )
𝑦2 − 𝑦1 𝑥2 − 𝑥1 𝑥2 − 𝑥1 𝑦2 − 𝑦1 𝑥2 − 𝑥1 𝑥2 − 𝑥1
1
= (𝑓(𝑄11 )(𝑥2 − 𝑥)(𝑦2 − 𝑦) + 𝑓(𝑄21 )(𝑥 − 𝑥1 )(𝑦2 − 𝑦))
(𝑥2 − 𝑥1 )(𝑦2 −𝑦1 )
+ (𝑓(𝑄12 )(𝑥2 − 𝑥)(𝑦 − 𝑦1 ) + 𝑓(𝑄22 )(𝑥 − 𝑥1 )(𝑦 − 𝑦1 ))
1 𝑓(𝑄11 ) 𝑓(𝑄12 ) 𝑦2 − 𝑦
𝑓(𝑥, 𝑦) = 𝑥2 − 𝑥 𝑥 − 𝑥1
(𝑥2 − 𝑥1 )(𝑦2 −𝑦1 ) 𝑓(𝑄21 ) 𝑓(𝑄22 ) 𝑦 − 𝑦1

12
2.3- Bilinear Interpolation
• Ex: Use bilinear interpolation, to get pixel
value of another point as shown figure.
• First linearly interpolating between the
values at column 14 and 15 on each rows 20
and 21, giving

• Then interpolating linearly between these


values, giving:
13
2.3- Bilinear Interpolation
• Ex: Supposed we have a 2x2 image and we want to decrease it to a
1x1 pixel using bilinear interpolation (Resolution Reduction):

1 2

6 5

14
2.4- Cubic Interpolation
• Using the values of the 4 neighboring points to form a cubic
function 𝑓 𝑥 = 𝑎𝑥 3 + 𝑏𝑥 2 + 𝑐𝑥 + 𝑑
 Form 4 equations using f (x1), f (x2), f (x3), and f (x4)
 Solve for the 4 coefficients {a,b,c,d}
 Find f (x‘ )

15
2.5- Matlab Implementation
• Group work of Matlab on:
 Resize image using Matlab function.
 Create own function for resolution reduction using average of
block 4x4.
 Use own function for image implementation, etc.

16
3- Introduction to Image Compression
• Image compression can be
lossless or lossy, although most
existing image compression
systems are lossy.
• The fundamental tasks in image
compression are to reduce the
irrelevancy and correlation in
the images.

A Typical Image Compression System


17
3- Introduction to Image Compression

1. The transform techniques are applied to the source image


blocks. For Discrete Cosine Transform (DCT) or Discrete
Wavelet Transform (DWT), coefficients are actually
transformed.
2. Quantization is followed by scalar or vector quantization to
reduce the number of bits required.
3. Finally, an entropy encoder such as run-length, Huffman or
arithmetic encoder is applied to achieve an even better
overall compression effect.

18
4- Lossy Image Compression

• The lossy compression aims at achieving a good compression ratio,


but the cost for it is the loss of some original information.
• The basic steps of lossy JPEG algorithm include offering a trade-off
between compression ratio and quality.
• An image can be compressed if its correlated pixels are
transformed to a new representation where the pixels become less
correlated. It is called “Transform technique”.
• Lossy compression can be achieved by quantisation of the
transformed values.
19
4- Lossy Image Compression
• The image decomposition or transformation is performed to
eliminate redundant information, or to provide a representation
that can be coded more efficiently.
• The difference between lossy and lossless technique is quantization.
• By quantizing the data, the number of possible output symbols is
reduced.
• The type and degree of quantization has a large impact on the bit
rate and quality of a lossy technique.
• The measure of a lossy compression algorithm normally includes a
measure of the quality of reconstructed images compared with the
original ones such as distortion measure. 20
4.1- Scalar Quantization
• The amplitude values obtained after sampling may be long real
numbers which are usually rounded to the nearest discrete values.
• This process of converting the real numbers to the predefined
discrete numbers is called quantization.

21
4.1- Scalar Quantization
• Example: Given a sequence of the
real numbers from some sampling
(1.1, 2, 3.3, 6.78, 5.48, 4, 3.333,
2.2, 2, 3, 2.1) and predefined
integers within a range of [0 10].
 So these sampled real
numbers can easily be
rounded to (1, 2, 3, 7, 5, 4, 3,
2, 2, 2).

22
4.1- Scalar Quantization
 Quantization is one of the simplest and most general ideas in
lossy compression.
 Quantization is the process in which a large range of values is
represented by a much smaller set of values.
 The function used to map the input sequence of values to the
output values is called quantizer.
 If the values we are looking at are scalars, the process is called
scalar quantization.

23
4.1- Scalar Quantization
• There are two types of scalar quantizers:
 midrise quantizer which does not have a zero output level.
 midtread quantizer where zero is one of the output values.

24
4.1.1- Uniform Quantizers
• A scalar quantizer can be divided into:
 uniform quantizer
 non-uniform quantizer.
• Uniform quantizers are those for which the same size of an
increment (called step size).
• If ki and ki-1 are two adjacent range values on the x axis, The
reconstructed values are usually the midpoint of the two
adjacent step values (ki - ki-1)/2 and (q(ki)- q(ki-1))/2 (Figure (b)).

25
4.1.1.1- Uniform Quantizers
• This indicates that distortion caused by the quantizer.
• The most common distortion measure is the mean squared error
distortion.

26
4.1.1- Uniform Quantizers
• The difference between quantized and unquantized values is
called quantization error, or round off error.

27
4.1.2- Non-uniform Quantizers
• Non-uniform quantizers use variable step sizes. It applies different
step sizes to different amplitudes of an input signal.
• Two common functional types are used in non-uniform quantisers:
power-law and logarithmic.

A symmetric nonuniform midrise quantizer. 28


Thank You

29

You might also like