Chapter-5 Data Compression
Chapter-5 Data Compression
DATA COMPRESSION
What is Data Compression?
• Data compression is the process of converting an input data stream or
the source stream or the original raw data into another data stream
that has a smaller size.
• For example text compression, image compression, audio
compression and video compression.
Why Data Compression?
• Uncompressed graphics, audio and video data require considerable
storage capacity , so data compression helps to save storage space.
• The same is true for multimedia communications. Data transfer take
smaller bandwidth and time by compressed multimedia as compare
to uncompressed one.
• So Data compression helps to provide feasible and cost effective
solutions for above two problems.
Types of Compression:
1. Lossy Compression :
• Lossy compression algorithms is normally not to reproduce an exact copy of the
source information after decompression but rather a version of it which is perceived
by the recipient as a true copy.
• In lossy compression some information is lost during the processing, where the
image data is stored into important and unimportant data. The system then discards
the unimportant data.
• It provides much higher compression rates but there will be some loss of
information compared to the original source file.
• The main advantage is that the loss cannot be visible to eye or it is visually lossless.
• Visually lossless compression is based on knowledge about color images and human
perception.
Contd…
2. Lossless Compression :
• In this type of compression no information is lost during the compression and
the decompression process.
• Here the reconstructed image is mathematically and visually identical to the
original one.
• It achieves only about a 2:1 compression ratio.
• This type of compression technique looks for patterns in strings of bits and
then expresses them more concisely.
Coding Requirements:
• Let us consider the general requirements imposed on most multimedia systems:
• Storage :
• Images require much more storage space than simple text; audio and video have even more
demanding properties for data storage.
• For example:
• a full screen true color image is 640 x 480 X 3 = 921600 bytes
• The size of one second of uncompressed CD quality stereo audio is 44.1kHz X 2 X 2 = 176400 bytes
• The size of one second of uncompressed PAL video is 384X288X 3 X 25 frames = 8294400 bytes
• Throughput:
• continuous media require very large throughput
• For example :
• an uncompressed CD quality stereo audio stream needs 176400 bytes/sec. A raw digitized PAL TV signal
needs(13.5MHz + 6.75MHz + 6.75MHz) X 8bits
• =216 X106 bits/sec = 27 X106 Bytes/sec
Calculation
• To determine storage requirements for the PAL standard, we assume
the same image resolution as 640 X 480 pixels and 3 bytes/pixel to
encode the luminance and chrominance components. Hence the
storage requirement for one image frame is 640 x 480 x 3
bytes=921,600 bytes or 7,372,800 bits. To store 25 frame/second, the
storage requirement is 230.4 x 10^5 bytes or 184.32x 10^6 bits.
Certain Constraints of Compression
Technique
• The quality of the coded, and later on, decoded data should be as
good as possible.
• To make cost-effective implementation possible, the complexity of the
technique used should be minimal.
• The processing of the algorithm must not exceed certain time span.
Techniques of Data Compression
• There are different important techniques of data compression:
Entropy Encoding
• Is lossless process
• Is used regardless of the media’s specific characteristics.
• The data stream to be compressed is considered to be a simple digital
sequence and the semantics of the data is ignored.
• It is lossless as decompression process regenerates the data
completely.
• Example: Run-length coding, Huffman coding, Arithmetic coding
Source Encoding
• Is a lossy process
• It takes into account the semantics of the data.
• degree of compression depends on data content.
• E.g. content prediction technique - DPCM, delta modulation
Hybrid Coding
• Most multimedia systems use hybrid techniques.
• combine entropy with source encoding
• E.g. JPEG, H.263, DVI (RTV & PLV), MPEG-1, MPEG-2, MPEG-4
Major Steps of Data Compression
Contd…
1. Picture Preparation:
• Preparation includes analog to digital conversion and generating an appropriate digital
representation of the information.
• An image is divided into blocks of 8x8 pixels, and represented by a fixed number of bits per
pixel.
2. Picture Processing:
• Processing is actually the first step of the compression process which makes use of
sophisticated algorithms.
• A transformation from the time to the frequency domain can be performed using DCT.
• In the case of motion video compression, interframe coding uses a motion vector for each
8x8 blocks.
• Motion video computation for digital video.
• This step can be repeated iteratively several time.
Contd…
3. Quantization:
• Quantization process the results of the previous step.
• It specifies the granularity of the mapping of real numbers into integers.
• This process results in a reduction of precision.
• For example they could be quantized using a different number of bits per coefficient.
For example 12 bits for real values, 8 bits for integer value.
• This step can be repeated iteratively several time.
4. Entropy Encoding:
• Entropy encoding is usually the last step.
• It compresses a sequential digit data stream without loss.
• For example, a sequence of zeroes in a data stream can be compressed by specifying
the number of occurrences followed by the zero itself.
Some Compression Technique:
Run Length Encoding:
• Sampled images, audio and video data streams often contain sequences of the
same bytes.
• By replacing these repeated byte sequences with the number of occurrences,
a substantial reduction of data can be achieved. This is called run length
encoding.
• To illustrate byte-stuffing, we define the exclamation mark “!” as a special flag.
• A single occurrence of this exclamation flag is interpreted as a special flag
during decompression.
• Two consecutive exclamation flags are interpreted as an exclamation mark
occurring within the data.
Contd…
• In this method, if a byte occurs at least four consecutive times, the
number of occurrences is counted.
• In the following example, the character “C” occurs 8 consecutive
times and is “compressed” to 3 characters “C!8”:
• Data: AAVVDDEEFFFFG12S4444
Contd
Diatomic encoding:
• It is a variation of run-length encoding based on a combination of two data
bytes.
• This technique determines the most frequently occurring pairs of bytes.
• According to an analysis of the English language, the most frequently occuring
pairs are the following:
• “e” and “t” ,”a” and “s”, “t” and “h” , “r” and “e”, “i” and “n”, “h” and “e” etc..
• This leads to a data reduction of more than 10%.
Contd…
• Huffman Encoding:
• Different characters do not have to coded with a fixed number of bits.
• Frequently-occurring characters are coded with shorter strings and seldom-
occurring characters are coded with longer strings.
• Huffman coding is based on this statistical methods.
• Given the characters that must be encoded, together with the probability of
their occurrences, the Huffman coding algorithm determines the optimal
code using the minimum number of bits.
• In text, the shortest code is assigned to those characters that occur most
frequently.
• To determine a Huffman code, it is useful to construct a binary tree.
Contd
• The leaves (node) of this tree represent the characters that are to be
encoded.
• Every node contains the occurrence probability of one of the
characters belonging to this subtree.
• 0 and 1 are assigned to the branches of the tree
• Question: Find Huffman coding for following:
Node A B C D E
Probability 0.16 0.51 0.09 0.13 0.11
Cond…
• We have:
• p(A)=0.16, p(B)=0.51, p(C)=0.09, p(D)=0.13, p(E)=0.11
• Characters with the lowest probabilities are combined in the first
binary tree, thus C and E are the leaves. The combined probability of
their root node CE is 0.20.
• The edge from node CE to C is assigned a 1 and the edge from CE to E
becomes a 0. This is an arbitrary assignment.
Contd…
• The following nodes remain:
• p(A)=0.16, p(B)=0.51, p(CE)=0.20, p(D)=0.13
• Again two nodes with the lowest probabilities are combined into a binary
tree:
• Nodes A and D and p(AD)=0.29
• Remaining nodes :
• P(AD)=0.29, p(B)=0.51, p(CE)=0.20
• Again:
• Nodes p(AD) and p(CE) with p(ADCE)=0.49
• Remaining nodes:
• P(ADCE)=0.49 and p(B)=0.51
Contd..
• Finally the root node p(ADCEB)=1.0
Contd..
• And the Huffman Code is:
• W(A)=001, w(B)=1, w(c )=011, w(D)=000, w(E )=010
JPEG(Joint Photographic Experts Group)
• JPEG is an image compression standard that was developed by the “Joint
Photographic Experts Group”.
• JPEG is a commonly used method of lossy compression for digital photography
(image).
• It employs a transform coding method using the DCT (Discrete Cosine Transform)
• The JPEG image compression standard became an international standard in 1992
• JPEG can be applied to color or grayscale images.
• A fast coding and decoding of still images is also used for video sequences known
as Motion JPEG.
• For detail information: click here
Requirements:
• The JPEG implementation should be independent of image size.
• The JPEG implementation should be applicable to any image and pixel
aspect ratio.
• Color representation itself should be independent of the special
implementation.
• Image content may be of nay complexity, with any statistical
characteristics.
• The JPEG standard specification should be state-of-the-art (or near)
regarding the compression factor and achieved image quality.
Four Variants of image compression of JPEG
1. The lossy sequential DCT-based mode must be supported by every
JPEG implementation.
2. The expanded lossy DCT-based mode provide’s set of further
enhancement to the baseline process.
3. The lossless mode has a low compression ratio that allows perfect
reconstruction of the original image.
4. The hierarchical mode accommodates images of different
resolutions and selects its algorithms from the three modes defined
above.
Main Step of JPEG Compression Process
Assignment #3