Module - 5 Image Data Compression
Module - 5 Image Data Compression
Compression
MODULE 5
Image Compression
➢The compression of images is carried out by an encoder and output a compressed form of an
image
➢Image compression is the process of encoding or converting an image file in such a way that it
consumes less space than the original file
➢It reduces the size of an image file without affecting or degrading its quality to a greater extent
➢ So, the total no of bits req= 1000*1000*8 = 80,00,000 bits per image
➢ We need a way to have proper representation as well to store the information about the image in a
minimum no of bits without losing the character of the image
➢In this stage codewords are generated for the different characters present
➢By doing so we aim to reduce the no. of bits required to represent the intensity levels and
represent them in an optimum number of bits.
➢And based on the probability of the occurrence of the character the length of the code is
determined
➢In order to have an optimum solution the most probable character has the smallest
length code
Huffman Coding
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Example:
Huffman Coding
Symbol S0 S1 S2 S3 S4
Probability 0.4 0.2 0.2 0.1 0.1
Huffman Coding
Arithmetic Coding
Arithmetic Coding
Example:
Arithmetic Coding
Example: Consider the probabilities p(a)=0.2, p(b)=0.3, p( c) =0.1,
p(d)=0.4.
➢JPEG compression uses the DCT (Discrete Cosine Transform) method for coding transformation
➢The JPEG standard works by averaging color variation and discard the information that the human eye
cannot see
How JPEG compression works
➢The raw image is first converted to a different color model, which separates the color of a pixel from its brightness
➢After that, DCT is applied to each block of pixels and converts the image from the spatial domain to the frequency
domain
➢Then make the resulting image quantized, because human eyes can not see high frequency
➢After quantization, zigzag scan is performed on these quantized 8×8 blocks to group the low-frequency coefficients
➢The coefficients is then encoded by Huffman coding to get the final image
Process Of JPEG Compression
How JPEG compression works
•Splitting –
We split our image into the blocks of 8*8 blocks. It forms 64 blocks in which each block is referred to
as 1 pixel.
•Apply DCT –
We apply Direct cosine transform on each block. The discrete cosine transform (DCT) represents an
image as a sum of sinusoids of varying magnitudes and frequencies.
How JPEG compression works
•Quantization –
In the Quantization process, we quantize our data using the quantization table.
•Serialization –
In serialization, we perform the zig-zag scanning pattern to exploit redundancy.
•Vectoring –
We apply DPCM (differential pulse code modeling) on DC elements. DC elements are used to define the strength
of colors.
•Encoding –
In the last stage, we apply to encode either run-length encoding or Huffman encoding. The main aim is to convert
the image into text and by applying any encoding we convert it into binary form (0, 1) to compress the data.
Advantages of JPEG
➢It has very good compression rate, image quality
➢JPEG is compatible with every computer, mobile devices, camera devices and also photo editors
➢The MPEG standards consist of three main parts: video, audio, and systems
➢MPEG algorithms compress data to form small bits that can be easily transmitted and then
decompressed
➢The video information is encoded using a technique called Discrete Cosine Transform (DCT)
MPEG
Function of MPEG :
Working of MPEG :
➢MPEG follows an algorithm in which the data are compressed into small bits
➢The compression rate of MPEG is high because it doesn’t store the complete frame, it only stores the
changes that has been done to the frames
➢Bi-directional prediction
MPEG
There currently are several MPEG standards.
➢MPEG-1 is intended for intermediate data rates, on the order of 1.5 Mbit/sec.
➢MPEG-3 was intended for HDTV compression but was found to be redundant and was merged
with MPEG-2.
➢MPEG-4 is intended for very low data rates of less than 64 Kbit/sec.
Morphological
Operation
Morphological Operation
➢It processes digital images based on their shapes
➢Each image pixel is corresponding to the value of other pixel in its neighborhood
➢By choosing the shape and size of the neighborhood pixel, you can construct a morphological
➢Morphological operations apply a structuring element called strel, to an input image, creating
➢In a morphological operation, the value of each pixel in the output image is based on a
comparison of the corresponding pixel in the input image with its neighbors.
Types of Morphological operations
•Dilation: Dilation adds pixels on the object boundaries.
•Open: The opening operation erodes an image and then dilates the eroded image, using the same
•Close: The closing operation dilates an image and then erodes the dilated image, using the same
➢Dilation adds pixels to the boundaries of objects in an image, while erosion removes pixels
on object boundaries
➢The number of pixels added or removed from the objects in an image depends on the size
and shape of the structuring element used to process the image
➢In the morphological dilation and erosion operations, the state of any given pixel in the
output image is determined by applying a rule to the corresponding pixel and its neighbors in
the input image
➢The rule used to process the pixels defines the operation as a dilation or an erosion.
Morphological Dilation
Morphological Dilation
➢The value of the output pixel is the maximum value of all pixels in the neighborhood.
➢In a binary image, a pixel is set to 1 if any of the neighboring pixels have the value 1.
➢Morphological dilation makes objects more visible and fills in small holes in objects.
➢Lines appear thicker, and filled shapes appear larger.
The following figure illustrates the dilation of a binary image.
The structuring element defines the neighborhood of the pixel
of interest, which is circled. The dilation function applies the
appropriate rule to the pixels in the neighborhood and assigns
a value to the corresponding pixel in the output image. In the
figure, the morphological dilation function sets the value of
the output pixel to 1 because one of the elements in the
Morphological neighborhood defined by the structuring element is on.
Dilation
Morphological Erosion
Morphological Erosion
➢The value of the output pixel is the minimum value of all pixels in the neighborhood. In a
binary image, a pixel is set to 0 if any of the neighboring pixels have the value 0.
➢Morphological erosion removes floating pixels and thin lines so that only substantive
objects remain.
➢Remaining lines appear thinner and shapes appear smaller.
Morphological Opening
➢The opening operation erodes an image and then dilates the eroded image, using the
➢Morphological opening is useful for removing small objects and thin lines from an
image while preserving the shape and size of larger objects in the image.
Morphological Opening
Morphological Closing
➢The closing operation dilates an image and then erodes the dilated image, using the
➢Morphological closing is useful for filling small holes in an image while preserving the