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

Chapter 5 Data Compression

Chapter 5 discusses data compression techniques essential for reducing storage space and bandwidth requirements for multimedia data. It covers various coding methods, including lossy and lossless techniques, and highlights the importance of compression in improving data transfer speed and processing efficiency. Key algorithms such as JPEG and MPEG are explained, detailing their processes and benefits in multimedia applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 5 Data Compression

Chapter 5 discusses data compression techniques essential for reducing storage space and bandwidth requirements for multimedia data. It covers various coding methods, including lossy and lossless techniques, and highlights the importance of compression in improving data transfer speed and processing efficiency. Key algorithms such as JPEG and MPEG are explained, detailing their processes and benefits in multimedia applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Chapter 5: Data Compression

▪ Storage Space ▪ Expanded Lossy DCT-based Mode


▪ Coding Requirements ▪ JPEG and MPEG
▪ Source, Entropy and Hybrid
Coding
▪ Lossy Sequential DCT-based Mode
Storage Space
• Uncompressed graphics, audio and video data require considerable storage
capacity which in the case of uncompressed video is often not even
feasible given today’s CD technology. The same is true for multimedia
communications.
• Data transfer of uncompressed video data over digital networks requires
very high bandwidth to be provided for a single point to point
communication. To provide feasible and cost effective solutions, most
multimedia systems usually use compressed digital video and audio data
streams.
• The most popular compression methods are JPEG (images), MPEG
(sound/video) and proprietary techniques including HQ Learn’s DVI (for
images, audio and video) from Microsoft and Apple.
Coding Requirements
• Images have higher storage requirements than text and video even
more.
• Let's have a comparison for a 640x480 window.
Text: 2 bytes for each 8x8 pixel character.
640x480/8x8=4800 characters per page X2bytes=9600 or 9.4KByte per page.

Vector images: A typical 640x480 image has 500 lines approximately. Each line
has 2 coordinates (x,y) each and an 8-bit attribute field. x requires 10 bits
(log2(640)) and y requires 9 bits (log2(480)).We need 46 bits per line ( ). The
storage required is 500x46/8=2875 or 2.8KByte per image.
Coding Requirements
• Bitmap images: Individual pixels of a bitmap can be coded using 256
different colours, requiring 1 Byte per pixel.640x480x1Byte= or
300KBytes per image.
• Sound: Uncompressed speech of telephone quality is sampled at
8kHz and quantized using 8 bits per sample, yielding a data stream of
64 Kbits/sec. Storage required will be (64Kbps/8)x(1sec/1024) =
8KByte for a 1 second sound.
• Sound: Uncompressed stereo audio signal of CD quality is sampled at
44.1kHz and quantized using 16 bits per sample, yielding a data
stream of 176,400 bytes/sec. Storage required will be 172KByte for a
1 second sound.
Coding Requirements
• Video: 25 full frames per second. Luminance(brightness) and
chrominance(signal used to convey color information) of each pixel
are coded using a total of 3 bytes. Data rate is
640x480x25x3bytes=23,040,000 bytes/sec. Storage required will be
21.98MByte for 1 second of video. (Multiply by 5 for HDTV!)
Data Compression
• Data compression is the process of modifying, encoding or converting
the bits structure of data in such a way that it consumes less space on
disk.
• It enables reducing the storage size of one or more data instances or
elements. Data compression is also known as source coding or bit-
rate reduction
Why Compression?
• To reduce the volume of data to be transmitted (text, fax, images)
• To reduce the bandwidth required for transmission and to reduce
storage requirements (speech, audio, video)
Importance of Data Compression
• Reduced Storage Costs: Compressed data requires less storage space, which can
significantly reduce storage costs for businesses dealing with large volumes of
data.
• Increased Data Transfer Speed: Smaller file sizes allow for faster data transfer
across networks and systems, improving overall data processing and
communication efficiency.
• Improved Data Processing and Analysis: Compressed data can be processed and
analyzed more quickly, enabling faster insights, decision-making, and advanced
analytics.
• Optimized Resource Utilization: By reducing the size of data files, compression
enables efficient utilization of computing resources, such as CPU cycles and
memory.
• Enhanced Data Security: Compression techniques can also be applied to encrypt
and secure data, protecting sensitive information from unauthorized access.
Data Compression Methods
Data Compression Methods
• Lossless Methods:
▪ the compression process does not reduce the amount of if information.
▪ Original can be reconstructed exactly.
• Lossy Methods:
▪ the compression process reduces the amount of information.
▪ Only an approximation of the original can be reconstructed.
Categories of Compression Techniques
• Entropy coding is lossless
• Source coding and hybrid coding are lossy.
Source, Entropy and Hybrid Coding

Fig: Rough Calculation of compression techniques in multimedia systems


Steps of Data Compression
Steps of Data Compression
1. Preparation:
• Preparation includes analog to digital conversion and generating an
appropriate digital representation of the information.
• An image is divided into blocks of 4*4 or 8*8 pixels, and represented by a
fixed number of bits per pixel.
2. Processing:
• This involves the conversion of the information from the time domain to the
frequency domain by using DCT (discrete cosine transform).
• In the case of motion video compression, inter frame coding uses a motion
vector for each 8*8 block.
Steps of Data Compression
3. Quantization:
• This step decides how detailed the information can be. Think of it like
rounding numbers to the nearest whole number instead of using lots of
decimal places.
• Sometimes, we round things in a regular way, and sometimes we do it
differently based on what the information looks like.
• The quantization process may be uniform or it may be differential depending
upon the characteristics of the picture.
4. Entropy Encoding:
• This is the lossless compression method where the semantics of data is
ignored but only its characteristics are considered.
• It doesn't care about what the data means; it just looks at how it's shaped.
Entropy coding
• Entropy coding is a technique used in multimedia to compress data
efficiently by assigning shorter codes to more frequently occurring
symbols or values.
• This reduces the overall size of the compressed data without losing
any information.
• Entropy coding includes:
a. Run length coding
b. Huffman Coding
c. Arithmetic Coding
Run length coding
• It is a lossless compression method where sequences that display
redundant data are stored as a single data value representing the
repeated block and how many times it appears in the image.
Arithmetic Coding
• Arithmetic coding is a lossless data compression technique that uses
the statistical properties of data to reduce its size.
• It works by assigning shorter codes to more frequent symbols and
longer codes to less frequent symbols.
Huffman Coding
• Huffman coding is a lossless data compression algorithm. It is a
lossless data compression mechanism.
• It is also known as data compression encoding. It is widely used in
image (JPEG or JPG) compression.
• The idea is to assign variable-length codes to input characters, lengths
of the assigned codes are based on the frequencies of corresponding
characters
Huffman Coding
Huffman encoding idea are mention in following steps:
• It assigns a variable-length code to all the given characters.
• The code length of a character depends on how frequently it occurs in
the given text or string.
• A character gets the smallest code if it frequently occurs.
• A character gets the largest code if it least occurs.
Huffman Coding – Example 1
• Consider the following input text:

• Frequencies of characters:

• Sorted order:

• As the above text is of 11 characters, each character requires 8 bits. Therefore,


a total of 11x8=88 bits are required to send this input text.
Huffman Coding – Example 1
• Now, we will create the Huffman tree.
Huffman Coding – Example 1
• Now, assign 0 to the left edges and 1 to the right edges of the
Huffman coding tree as shown below.

• Without using the Huffman coding algorithm, the size of the text was 88 bits.
Whereas after encoding the text, the size is reduced to 24 + 11 + 16 = 51 bits.
Huffman Coding – Example 2
Huffman Coding – Example 2
Huffman Coding – Example 2
Huffman Coding – Example 2
• We assign a weight to each edge. Note that each left edge-weighted is
0 and the right edge-weighted is 1.
Huffman Coding – Example 2
• Here, no of character = 6
• No of bits required to represent character = 2^3 i.e. code length will
be 3.
• Bits used before coding: 5*3 +9*3 + 12*3 + 13*3 +16*3 + 45*3 = 300
• Bits used after coding: 5*4 + 9*4 + 12*3 + 13*3 + 16*3 + 45*0 = 179
• Therefore, (300-179)/300 = 40.3% of space is saved after Huffman
coding
Assignment
1. Find the Average Code Length for the String and Length of the
Encoded String of the given string “abcdrcbd”. Use the Huffman
coding technique to find the representation bits of the character.
Hints:
• Average Code Length = ∑ ( frequency × code length ) / ∑ ( frequency )
• Length= Total number of characters in the text x Average code length per character

2. Differentiate between lossy compression and lossless compression


methods.
JPEG
• JPEG stands for Joint Photographic Experts Group and is a lossy
compression algorithm that results in significantly smaller file sizes
with little to no perceptible impact on picture quality and resolution.
• A JPEG-compressed image can be ten times smaller than the original
one.
• JPEG works by removing information that is not easily visible to the
human eye while keeping the information that the human eye is good
at perceiving.
Why we need image compression?
• Let us take an example, A typical digital image has 512x480 pixels.
• In 24-bit colour (one byte for each of the red, green and blue
components), the image requires 737,280 bytes of storage space.
• It would take about 1.5 minutes to transmit the uncompressed image
over a 64kb/second link.
• The JPEG algorithms offer compression rates of most images at ratios
of about 24:1.
• Effectively, every 24 bits of data is stuffed into 1 bit, giving a
compressed file size (for the above image dimensions) of 30,720
bytes, and a corresponding transmission time of 3.8 seconds.
JPEG
There are some requirements of JPEG standard and they are:
• Independent of image size - The JPEG implementation should be able to handle images of
any size, without any special requirements.
• Applicable to any image and pixel aspect ratio - The JPEG implementation should be able
to handle images of any type, including grayscale, color, and RGB images, with any pixel
aspect ratio.
• Color representation independent of implementation - The JPEG implementation should
not be specific to any particular color representation format.
• Image content of any complexity - The JPEG implementation should be able to handle
images of any complexity, with any statistical characteristics.
• State-of-the-art compression and image quality - The JPEG implementation should use
the latest and greatest compression techniques to achieve the best possible image quality
for a given compression ratio.
• Processing complexity for software and specialized hardware - The JPEG implementation
should be efficient enough to run on standard processors, but should also be able to take
advantage of specialized hardware to improve performance and image quality.
Steps of JPEG Compression process
Steps of JPEG Compression process
• Step 1: The input image is divided into a small block which is having
8x8 dimensions. This dimension is sum up to 64 units. Each unit of
the image is called pixel.
Steps of JPEG Compression process
• Step 2: JPEG uses [Y,Cb,Cr] model instead of using the [R,G,B] model.
So in the 2nd step, RGB is converted into YCbCr.
• YCbCr consists of 3 different channels: Y is the luminance channel
containing brightness information, and Cb and Cr are chrominance
blue and chrominance red channels containing color information.
• In this color space, JPEG can make changes to the chrominance
channel to change the image’s color information without affecting the
brightness information that is located in the luminance channel.
• After conversion, each pixel has three new values that represent the
luminance, the chrominance blue, and the chrominance red
information.
Steps of JPEG Compression process
• Step 3: After the conversion of colors, it is forwarded to DCT. DCT uses a
cosine function and does not use complex numbers. It converts
information which are in a block of pixels from the spatial domain to the
frequency domain.

• Using DCT, for each channel, each block of 64 pixels can be reconstructed
by multiplying a constant set of base images by their corresponding weight
values and then summing them up together. Here is what the base images
look like:
Steps of JPEG Compression process

• For every block of 64 pixels, we’ll have three weight matrices, one for
luminance and two for chrominance. In addition, no information is
lost in this phase.
Steps of JPEG Compression process
• Step 4: Human eyes can't see some image details with high
frequencies.
• DCT matrix keeps only low-frequency information.
• To use fewer bits, we do quantization.
• We divide by a preset table and round to nearest whole number
Steps of JPEG Compression process
• Here is what a quantization table for chrominance channels looks like:
for the luminance channel:
Steps of JPEG Compression process
• We can see that the quantization tables have higher numbers at the
bottom right, where high-frequency data is located, and have lower
numbers at the top left, where low-frequency data is located. As a result,
after dividing each weight value, high-frequency data is rounded to 0:

• Now we have three matrices containing integer values for every block of 64
pixels, one for luminance and two for chrominance.
Steps of JPEG Compression process
• Now all that’s left to do is to list the values that are inside each
matrix, run RLE (Run Length Encoding) since we have a lot of zeroes,
and then run the Huffman Coding algorithm before storing the data.
• RLE and Huffman Coding are lossless compression algorithms that
reduce the space needed to store information without removing any
data.
• As we can see, the result of quantization has many 0s toward the
bottom left corner. To keep the 0 redundancy, the JPEG algorithm
does a zig-zag scanning pattern that keeps all zeroes together:
Steps of JPEG Compression process
• After zig-zag scanning, we get a list of integer values, and after
running RLE on the list, we get each number and how many times
they’re repeated.
• Finally, JPEG runs Huffman coding on the result, and the values that
have more frequency (like the zeroes) are represented with fewer bits
than less frequent values.
• No data is lost during this phase.
MPEG compression process
• MPEG stands for Moving Picture Coding Exports Group.
• MPEG algorithms compress data to form small bits that can be easily
transmitted and then decompressed.
• MPEG achieves its high compression rate by storing only the changes
from one frame to another, instead of each entire frame.
• The information is then encoded using a technique called Discrete
Cosine Transform (DCT).
• MPEG uses a type of lossy compression, since some data is removed.
But the diminishment of data is generally imperceptible to the human
eye
MPEG compression process
• MPEG compression removes two types of redundancies:
• Spatial redundancy:
▪ Pixel values are not independent, but are correlated with their neighbour
both within the same frame and across frames. So, to some extent, the value
of a pixel is predictable given the values of neighbouring pixels.
▪ It is removed with the help of DCT compression
MPEG compression process
• Temporal redundancy:
▪ Pixels in two video frames that have the same values in the same location
(some objects repeated again and again in every frame).
▪ It is removed with the help of Motion compensation technique Macroblock
▪ It is the basic hierarchical component used achieving high level of
compression.
▪ The key to achieving a high rate of compression is to remove much redundant
information as possible.
▪ Entropy encoding and Huffman coding are two schemes used for encoding
video information.
▪ MPEG takes the advantage of the fact that there exists a correlation between
successive frames of moving pictures.
MPEG compression process
MPEG compression process
• The MPEG compression algorithm encodes the data in 5 steps.
• First a reduction of the resolution is done, which is followed by a
motion compensation in order to reduce temporal redundancy.
• The next steps are the Discrete Cosine Transformation (DCT) and a
quantization as it is used for the JPEG compression; this reduces the
spatial redundancy (referring to human visual perception).
• The final step is an entropy coding using the Run Length Encoding and
the Huffman coding algorithm
MPEG compression process
Step 1: Reduction of the Resolution
• The human eye has a lower sensibility to colour information than to
dark-bright contrasts.
• A conversion from RGB-colour-space into YUV colour components
help to use this effect for compression.
• The chrominance components U and V can be reduced (subsampling)
to half of the pixels in horizontal direction (4:2:2), or a half of the
pixels in both the horizontal and vertical (4:2:0).
MPEG compression process
Step 2: Motion Estimation
• An MPEG video can be understood as a sequence of frames. Because
two successive frames of a video sequence often have small
differences (except in scene changes), the MPEG-standard offers a
way of reducing this temporal redundancy.
• It uses three types of frames: I-frames (intra), P-frames (predicted)
and B-frames (bidirectional).
MPEG compression process
• The I-frames are “key-frames”, which have no reference to other frames
and their compression is not that high.
• The P-frames can be predicted from an earlier I-frame or P-frame.
• P-frames cannot be reconstructed without their referencing frame, but
they need less space than the I-frames, because only the differences are
stored.
• The B-frames are a two directional version of the P-frame, referring to both
directions (one forward frame and one backward frame).
• B-frames cannot be referenced by other P- or B-frames, because they are
interpolated from forward and backward frames.
• P-frames and B-frames are called inter coded frames, whereas I-frames are
known as intra coded frames.
MPEG compression process
• The references between the different types of frames are realized by
a process called motion estimation or motion compensation.
• The correlation between two frames in terms of motion is
represented by a motion vector.
• The resulting frame correlation, and therefore the pixel arithmetic
difference, strongly depends on how good the motion estimation
algorithm is implemented.
MPEG compression process
The steps involved in motion estimation:
• Frame Segmentation - The Actual frame is divided into non
overlapping blocks (macro blocks) usually 8x8 or 16x16 pixels. The
smaller the block sizes are chosen, the more vectors need to be
calculated.
• Search Threshold - In order to minimize the number of expensive
motion estimation calculations, they are only calculated if the
difference between two blocks at the same position is higher than a
threshold, otherwise the whole block is transmitted.
MPEG compression process
• Block Matching - In general block matching tries to “stitch together”
an actual predicted frame by using snippets (blocks) from previous
frames.
• Prediction Error Coding - Video motions are often more complex, and
a simple “shifting in 2D” is not a perfectly suitable description of the
motion in the actual scene, causing so called prediction errors.
• Vector Coding - After determining the motion vectors and evaluating
the correction, these can be compressed. Large parts of MPEG videos
consist of B- and P-frames as seen before, and most of them have
mainly stored motion vectors.
MPEG compression process
Step 3: Discrete Cosine Transform (DCT)
• DCT allows, similar to the Fast Fourier Transform (FFT), a
representation of image data in terms of frequency components.
• So the frame-blocks (8x8 or 16x16 pixels) can be represented as
frequency components. The transformation into the frequency
domain is described by the following formula:
MPEG compression process
Step 4: Quantization:
• During quantization, which is the primary source of data loss, the DCT
terms are divided by a quantization matrix, which takes into account
human visual perception.
• The human eyes are more reactive to low frequencies than to high
ones. Higher frequencies end up with a zero entry after quantization
and the domain was reduced significantly.
MPEG compression process
Step 5: Entropy Coding
• The entropy coding takes two steps: Run Length Encoding (RLE ) [2]
and Huffman coding [1]. These are well known lossless compression
methods, which can compress data, depending on its redundancy, by
an additional factor of 3 to 4.
Assignment
• Lossy Sequential DCT-based Mode
• Expanded Lossy DCT-based Mode

[email protected]

You might also like