You are on page 1of 22

Multimedia Technologies

UNIT-3

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹
Data Compression

• Compression is the way of making files to take up less space.

• In multimedia systems, in order to manage large multimedia data objects


efficiently, these data objects need to be compressed to reduce the file size for
storage of these objects.
• Compression tries to eliminate redundancies in the pattern of data.

• Storing or sending smaller number of bits.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Data Compression Algorithms

Although many methods are used for this purpose, in general


these methods can be divided into two broad categories:
lossless and lossy methods.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Lossy Data Compression

• Lossy data compression is named for what it does.


• After one applies lossy data compression to a message, the
message can never be recovered exactly as it was
before it was compressed.
• When the compressed message is decoded it does not give
back the original message.
• Data has been lost.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Loseless Data Compression

• Original message can be exactly decoded.

• Lossless data compression works by finding repeated


patterns in a message and encoding those patterns in an
efficient manner.

• For this reason, lossless data compression is also referred


to as redundancy reduction.

• Because redundancy reduction is dependent on patterns in


the message, it does not work well on random messages.

• Lossless data compression is ideal for text..

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Dynmaic Huffman Coding

• Difference between dynamic Huffman coding and Huffman


coding

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Arithmetic Technique

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Arithmetic vs Huffman Coding

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
.

Run Length Coding

• Run-length encoding (RLE) is a form of lossless data


compression in which runs of data are stored as a single data value
and count, rather than as the original run.

• This is most efficient on data that contains many runs.

• For files that do not have many runs, RLE could increase the file
size.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Example - Run Length Coding
For example, if the input string is “wwwwaaadexxxxxx”, then the function
should return “w4a3d1e1x6”

Follow the steps below to solve this problem:

1. Pick the first character from the source string.

2. Append the picked character to the destination string.

3. Count the number of subsequent occurrences of the picked character


and append the count to the destination string.

4. Pick the next character and repeat steps 2, 3 and 4 if the end of the
string is NOT reached.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Lempel–Ziv–Welch (LZW) Algorithm

• The LZW algorithm is a very common compression technique.

• This algorithm is typically used in GIF and optionally in PDF and TIFF.

• It is lossless, meaning no data is lost when compressing.

• The algorithm is simple to implement and has the potential for very high
throughput in hardware implementations.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Lempel–Ziv–Welch (LZW) Algorithm
• It is the algorithm of the widely used Unix file compression utility
compress and is used in the GIF image format.

• The Idea relies on reoccurring patterns to save data space.

• LZW is the foremost technique for general-purpose data compression


due to its simplicity and versatility.

• It is the basis of many PC utilities that claim to “double the capacity of


your hard drive”.

• LZW compression works by reading a sequence of symbols, grouping


the symbols into strings, and converting the strings into codes.

• Because the codes take up less space than the strings they replace, we
get compression.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Lempel–Ziv–Welch (LZW) Algorithm
Characteristic features of LZW includes:

• LZW compression uses a code table, with 4096 as a common choice for
the number of table entries.
• Codes 0-255 in the code table are always assigned to represent single
bytes from the input file.
• When encoding begins the code table contains only the first 256 entries,
with the remainder of the table being blanks. Compression is achieved
by using codes 256 through 4095 to represent sequences of bytes.
• As the encoding continues, LZW identifies repeated sequences in the
data and adds them to the code table.
• Decoding is achieved by taking each code from the compressed file and
translating it through the code table to find what character or characters
it represents.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Arithmetic Technique

• Arithmetic coding is a popular compression algorithm after Huffman coding.

• It is particularly useful for a relatively small and skewed alphabet.

• Arithmetic coding algorithm encodes an entire file as a sequence of symbols


into a single decimal number.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Transform Coding

• The purpose of transformation is to convert the data into a form where


compression is easier.

• „Facilitates reduction of irrelevant information.

• ‡ he transform coefficients can be quantized according to their statistical


T
properties.

• „The transformation will reduce the correlation between the pixels.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Transform Coding
• Transform methods are typically used in filtering, compression, and image
texture analysis.

• Transform coding compresses image data by representing the original signal


with a small number of transform coefficients.

• It exploits the fact that for typical images a large amount of signal energy is
concentrated in a small number of coefficients.

• Transform coding is an integral part of the Joint Photographic Experts Group


(JPEG) standard for lossy image compression.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Transform Coding
In this coding, we consider compression techniques that are based on modifying
the transform of an image.

In transform coding, a reversible, linear transform (such as the Fourier transform)


is used to map the image into a set of transform coefficients, which are then
quantized and coded.

For most natural images, a significant number of the coefficients have small
magnitudes and can be coarsely quantized (or discarded entirely) with little image
distortion.

A variety of transformations, including the discrete Fourier transform (DFT), can


be used to transform the image data.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Transform Coding

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
• Image is divided into a set of images.

• N*N image is decomposed into a set of sub-images of size n*n

• Values of n is a power of 2.

• Step is necessary to reduce computational complexity.

• The goal of the transformation process is to decorrelate the


pixels of each subimage.

• Or to pack as much information as possible into the smallest


number of transform coefficients.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Transform Coding
• The quantization stage then selectively eliminates or more coarsely quantizes the
coefficients that carry the least information.

• These coefficients have the smallest impact on reconstructed sub-image quality.

• The encoding process terminates by coding (normally using a variable-length


code) the quantized coefficients.

• Any or all of the transform encoding steps can be adapted to local image content,
called adaptive transform coding, or fixed for all sub-images, called non-adaptive
transform coding.

• The decoder implements the inverse sequence of steps (with the exception of the
quantization function) of the encoder, which performs four relatively
straightforward operations: subimage decomposition, transformation,
quantization, and coding.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Pattern Substitution

• This is a simple form of statistical encoding.

• Here, we substitute a frequently repeating pattern(s) with a code.

• The code is shorter than pattern giving us compression.

• A simple Pattern Substitution scheme could employ predefined code (for


example replace all occurrences of `The' with the code '&').

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›
Pattern Substitution

More typically tokens are assigned to according to frequency of occurrence of


patterns:

• Count occurrence of tokens

• Sort in Descending order

• Assign some symbols to highest count tokens

A predefined symbol table may used i.e. assign code i to token i.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63,by Dr. Saumya U3.‹#›

You might also like