Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

ECE 4007

Information Theory and Coding

J COMPONENT

TOPIC: JPEG COMPRESSION BY DCT TECHNIQUES


SUBMITTED BY:

PRAKHAR JAIN -16BEC0090

ANIKET SARKAR-16BEC0402

CHAITENAYA GOEL-16BEC0580

SLOT: B1+TB1

UNDER THE GUIDANCE OF: Prof. THANIKAISELVAN V (SENSE)

VIT, Vellore

OBJECTIVE OF PROJECT

JPEG is an image compression standard developed by a joint ISO/CCIT committee known as


the Joint Photographic Experts Group. Basically JPEG has two compression methods. One is
the DCT based “lossy” compression and second is the predictive method for “lossless”
compression.

This project provides an overview of the DCT based JPEG lossy compression technique and
the steps involved in it. The steps of this algorithm will be explained briefly throughout the
project and the steps will be implemented in MATLAB.

The remarkable quality of JPEG is that it achieves high compression ratios with little loss in
quality. The aim of this project is to compress the size of jpeg image without much loss
in quality. JPEG format is quite popular and is used in a number of devices such as digital
cameras and is also the format of choice when exchanging large sized images in a bandwidth
constrained environment such as the Internet.

Following tasks are made easier with usage of JPEG Compression:-

• Storing in a physical device


• Sending with GPRS
• Sending with MMS
• Shot to shot time latency
• Video clip transmission (cost)
• Streaming - real time video conference (bandwidth, cost)

JPEG can’t be used for images with sharp edges, lines as it causes a Ringing effect on the
edges. It is best on photographs and paintings of realistic scenes with smooth variations of
tone and colour. JPEG is also not well suited to files that will undergo multiple edits, as
some image quality will usually be lost each time the image is decompressed and
recompressed.
BLOCK DIAGRAM

JPEG compression will be implemented using MATLAB. The following methods will be
used for the same:-

I. Color space transformation


II. Down sampling
III. Block splitting
IV. DCT and Quantization
V. Entropy coding

Using the above methods, we can perform JPEG compression using MATLAB.
Need for Compression Technique

Ø Compression is an important component of the solutions available for creating file


sizes of manageable and transmittable dimensions.

Ø An image, 1024 pixel x 1024 pixel x 24 bit, without compression, would require 3 MB
of storage and 7 minutes for transmission, utilizing a high speed, 64 Kbit/s, ISDN line.
If the image is compressed at a 10:1 compression ratio, the storage requirement is
reduced to 300 KB and the transmission time drops to under 6 seconds.

Ø So compression requirement can be explained from both Engineer point of view &
Layman point of view. As an Engineer point of view large image files require more
bandwidth thus high cost is an issue. As a layman point of view device storage
problem can occur due to large image files.

More Bandwidth Requirement Device Storage Problem

Trade-off Between Quality & Efficiency à

• JPEGà huge compression but quality may degrade(Lossy compression).


• PNGà Quality better (lossless compression) but less amount of compression.
Now a days Social media like Facebook, Instagram , WhatsApp etc. are an integral part of
this Digital era. As these apps are device storage draining apps so little quality
degradation if image is fine, , but want to have a space in MOBILE ! That is the motivation
to go for JPEG lossy compression technique.

Methodology of DCT Transformation

1) COLOR SPACE TRANSFORMATION: The DCT transforms a signal from a SPATIAL


REPRESENTATION into a frequency representation. A digital image is a grid of pixels.
Each pixel corresponds to any one value called pixel intensity. Let I be an image and (x,y) is
the location (or coordinate) of any pixel then an image I(x,y) is a matrix of pixels.

Now the image should be converted from RGB into a different color
space called YCbCr. It has three components Y, Cb and Cr: the Y
component represents the brightness of a pixel, the Cb and Cr
components represent the chrominance (split into blue and red
components).

Pixels of an image

Using the relation below, RGB is converted to YCbCr.


YCbCr is therefore used to produce a difference between luminance and chrominance.

• Luminance: received brightness of the light, which is proportional to the total energy in
the visible band.
• Chrominance: the perceived color tone of a light, which depends on the wavelength
composition of light chrominance is in turn characterized by two attributes – hue and
saturation.
1. Hue: Specify the color tone, which depends on the peak wavelength of the light
2. Saturation: Describe how pure the color is, which depends on the spread or
bandwidth of the light spectrum. Y is the brightness (luma), Cb is blue minus luma (B-Y)
and Cr is red minus luma (R-Y).

2) DOWN SAMPLING :The transformation into the YCbCr color model enables the next
step, which is to reduce the spatial resolution of the Cb and Cr components (called "down
sampling" or "chroma subsampling"). The ratios at which the down sampling can be done on
JPEG are 4:4:4 (no down sampling),4:2:2 (reduce by factor of 2 in horizontal direction), and
most commonly4:2:0 (reduce by factor of 2 in horizontal and vertical directions).
3) BLOCK SPLITTING:
After subsampling, each channel must be split into 8 ×8 blocks of pixels. Depending on
chroma subsampling, this yields (Minimum Coded Unit) MCU blocks of size 8 ×8 (4:4:4 –
no subsampling), 16 ×8 (4:2:2), or most commonly 16 ×16 (4:2:0).

4) DISCRETE COSINE TRANSFORM :


• The coefficients of Discrete cosine transform are found using Fast Fourier transform.
• We use Radix 2 FFT 8 point transform to find the coefficients.
• We use Decimation in frequency algorithm (DIF) as it takes less time to compute.

FFT Algorithm for DCT coeff.

5) Coefficient matrix: Blocks above are that of low frequency (high energy) and those below
are the ones with high frequency (low energy) which will be further removed.
Low frequency signalà slowly varying signal.
High frequency signalà includes a sharp edge.

♦ Why High Frequency signals are removed?


For most images, MUCH OF THE SIGNAL ENERGY LIES AT LOW
FREQUENCIES. Low frequency represents a smooth area, and most part of an image
doesn't have abrupt change which can explain “NATURAL IMAGE HAS MORE
LOW FREQUENCY”.
Whereas High frequency components have very small energy which is small
enough to be neglected with little visible distortion.

DCT CALCULATION METHOD

We represent the pixels as sum of cosine signals of different frequencies. As image is


basically nothing but signal , so the fact is applicable for image too Any pixel can be
represented as sum of cosine wave of 8 different frequencies.

For 1D image the formula isà

The general equation for a 2D(N by M image) DCT is à

Basic Steps :
♦ Split image into 8 cross 8 pixel
♦ Represent each pixel by diff. cosine signals.
♦ Remove the high frequency components(compression).
Each component (Y, Cb, Cr) of each 8×8 block is converted to a frequency-domain
representation, using a normalized, two-dimensional type-II discrete cosine transform (DCT).

ALGORITHM OF DCT TRANSFORMATION


Step1: Consider the following as an example of an 8x8 sub image:

Before computing the DCT of the subimage, its gray values are shifted from a positive range
to one centered around zero. For an 8-bit image each pixel has 256 possible values: [0,255].
To center around zero it is necessary to subtract by half the number of possible values, or
128.
Step2: Subtracting 128 from each pixel value yields pixel values on [ − 128,127].
Step3: The next step is to take the two-dimensional DCT, which is given by:

If this transformation is performed on the above matrix,

Note the rather large value of the top-left corner. This is the DC coefficient. The remaining
63 coefficients are called the AC coefficients.

Step4: Consider a typical Quantization matrix:

Step 5 : We get the following matrix by dividing corresponding Coefficient matrix values
and Quantization matrix values.
For example, using −415 (the DC coefficient) and rounding to the nearest integer,

This process helps us to remove high frequency components from the right downward side
of the matrix. This therefore compresses the image with loss in its space but not much
noticeable changes in the image.

MATLAB CODE ALGORITHM


. 1) Start the code

. 2) Initialize the rows and columns of the matrix and other variables used in the forming
the matrix

. 3) Take any image and read that image

. 4) First convert the image from RBG to YCbCr

. 5) Using the above algorithm find the down sampled image

. 6) Now start the DCT algorithm with 8x8 Image block

. 7) Form the matrix required for Quantization

. 8) Then start the Quantization process by subtracting 128 from each element of the matrix

. 9) Using the Quantization table matrix round of the each value and display the matrix

10)From now start the inverse DCT process

11) In inverse DCT each element should be added 128 value to each element of the matrix

12) Display the original image and the compressed image


RESULT:
Using the above methods, we can perform JPEG compression (upto 3 times for the image used)
using MATLAB.
CONCLUSION:

♦ DCT is used for transformation in JPEG standard. DCT performs efficiently at


medium bit rates. Disadvantage with DCT is that only spatial correlation of the
pixels inside the single 2-D block is considered and the correlation from the
pixels of the neighboring blocks is neglected. Blocks cannot be decorrelated at
their boundaries using DCT.

♦ We focused on the Fast and efficient lossy coding algorithms JPEG for image
Compression/Decompression using Discrete Cosine transform. We also briefly
introduced the principles behind the Digital Image compression and various
image compression methodologies and the jpeg process steps including DCT,
quantization , entropy encoding.

REFERENCES :
• Mathworks.com
• A.M.Raid , W.M.Khedr , M. A. El-dosuky and Wesam Ahmed “Jpeg Image Compression Using
Discrete Cosine Transform - A Survey” International Journal of Computer Science & Engineering
Survey (IJCSES) Vol.5, No.2, April 2014.
• Andrew B. Watson, NASA Ames Research Center “Image Compression Using the Discrete Cosine
Transform”.

You might also like