SlideShare a Scribd company logo
1 of 40
Data Compression
Presented to: Prof. Dr. Maha Sharkas
presented by: Sherif Mohamed

1
Data Compression
Outline
1)
2)
3)
4)
5)
6)

Introduction.
Types of Data Compression.
Lossless Compression.
Lossless Algorithms.
Lossy Compression.
Lossy Algorithms .
2
Data Compression
• It is the process of reducing the amount of
data required to represent a given quantity of
information.
• Save time and help to optimize resources
i. In sending data over communication line:
less time to transmit and less storage to
host.
• Reduce length of data transmission time over
the network.
3
Types of Data Compression
1. Lossless Compression.
2. Lossy Compression.

4
Data Compression Algorithm
• Lossless Compression
If the compressed data is reconstructed and
the original data is obtain without any loss of
information then this technique is called
lossless compression.

5
Types of Data Compression
• Lossy Compression
If the compressed data is reconstructed and
the approximation of original data is obtain
and loss of information occurs then this
technique is called lossy compression.
The original message can never be recovered
exactly as it was before it was compressed.

6
Types of Data Compression

Lossless

Original Data

Compressed
Data

Original Data
Approximated

7
Data Compression Algorithm

8
Lossless Algorithm
• Huffman Encoding
 There’s no unique Huffman code.
 Algorithm:
①
②

③

Make a leaf node for each code symbol
Add the generation probability of each symbol to the leaf node
Take the two leaf nodes with the smallest probability and connect them into
a new node
Add 1 or 0 to each of the two branches
The probability of the new node is the sum of the probabilities of the
two connecting nodes
If there is only one node left, the code construction is completed. If not, go
back to (2)

9
Huffman Coding
• z

10
Huffman Coding
• Encoding

• Decoding

11
Lossless Algorithm
• Lempel Ziv Walsh (LZW) Encoding
• It is dictionary based encoding
• Basic idea:
 Create a dictionary or a code table of strings used during
communication.
 If both sender and receiver have a copy of the dictionary, then
previously-encountered strings can be substituted by their index
in the dictionary.

• LZW to compress text, executable code and similar
data files to about one half their original size.
12
LZW Coding
 Have 2 phases:
 Building an indexed dictionary
 Compressing a string of symbols

• Algorithm:
 Extract the smallest substring that cannot be found in the
remaining uncompressed string.
 Store that substring in the dictionary as a new entry and
assign it an index value
 Substring is replaced with the index found in the dictionary
 Insert the index and the last character of the substring into
the compressed string
13
LZW Coding
• Lempel Ziv Compression

14
15
LZW Coding
• Lempel Ziv Decompression

16
17
Lossless Algorithm
• Run Length Encoding
• Simplest method of compression.
• Replace consecutive repeating occurrences of
a symbol by 1 occurrence of the symbol itself,
then followed by the number of occurrences.

18
Run Length Coding
• The method can be more efficient if the data
uses only 2 symbols (0s and 1s) in bit patterns
and 1 symbol is more frequent than another.

19
Lossy Algorithm
• Used for compressing images and video files (our
eyes cannot distinguish subtle changes, so lossy data
is acceptable).
• These methods are cheaper, less time and space.
• Several methods:
 JPEG: compress pictures and graphics
 MPEG: compress video
 MP3: compress audio

20
Lossy Algorithm
• JPEG Encoding
• Used to compress pictures and graphics.
• In JPEG, a grayscale picture is divided into 8x8
pixel blocks to decrease the number of calculations.
• Basic idea:
 Change the picture into a linear (vector) sets of numbers that
reveals the redundancies.
 The redundancies is then removed by one of lossless

21
JPEG Encoding

22
JPEG Encoding
• DCT(Discrete Cosine Transform)
• Image is divided into blocks of 8*8 pixels.
• For grey-scale images, pixel is represented by 8-bits.
• For color images, pixel is represented by 24-bits or
three 8-bit groups.

23
JPEG Encoding
• DCT takes an 8*8 matrix and produces another 8*8
matrix and its values represent by this equation:

T[i][j] = 0.25 C(i) C(j) ∑ ∑ P[x][y] Cos(2x+1)iπ/16
* Cos (2y+1)jπ/16
 i = 0, 1, …7, j = 0, 1, …7
 C(i) = 1/√2, i =0
= 1 otherwise
T contains values called ‘Spatial frequencies’
24
JPEG Encoding
• T[0][0] is called the DC coefficient, related to
average values in the array, Cos 0 = 1
• Other values of T are called AC coefficients, cosine
functions of higher frequencies
 Case 1: all P’s are same, image of single color with no variation
at all, AC coefficients are all zeros.
 Case 2: little variation in P’s, many, not all, AC coefficients are
zeros.
 Case 3: large variation in P’s, a few AC coefficients are zeros.
25
JPEG Encoding

26
JPEG Encoding
P-matrix
T-matrix
• 20 30 40 50 60 …
720 -182 0 -19 0 …
30 40 50 60 70
-182 0 0 0 0
40 50 60 70 80
0
0 0 0 0
50 60 70 80 90
-19 0 0 0 0
60 70 80 90 100
0
0 0 0 0
…
…
‘Uniform color change and little fine detail, easier to
compress after DCT’
27
JPEG Encoding
P-matrix
T-matrix
• 100 150 50 100 100 …
835 15 -17 59 5…
200 10 110 20 200
46 -60 -36 11 14
10 200 130 30 200
-32 -9 130 105 -37
100 10 90 190 120
59 -3 27 -12 30
10 200 200 120 90
50 -71 -24 -56 -40
….
….
‘Large color change, difficult to compress after DCT’
28
JPEG Encoding
• Quantization
• Provides an way of ignoring small differences in an
image that may not be perceptible.
• Another array Q is obtained by dividing each
element of T by some number and rounding-off to
nearest integer ( The loss is occur in this step)

29
JPEG Encoding
T-matrix
Q-matrix
• 152 0 -48 0 -8…
15 0 -5 0 -1…
0 0 0 0 0
0 0 0 0 0
-48 0 38 0 -3
-5 0 4 0 0
0 0 0 0 0
0 0 0 0 0
-8 0 -3 0 13
-1 0 0 0 1
…
…
‘Divide by 10 and round-off ’
.
30
JPEG Encoding
• Dividing T-elements by the same number is not
practical, may result in too much loss.
• Retain the effects of lower frequencies as much as
possible.
• To define a quantization array Q, then
Q[i][j] = Round (T[i][j] ÷ U[i][j]),
i = 0, 1,.........7, j = 0, 1, …7

31
JPEG Encoding
• U = 1 3 5 7 9… Q= 152 0 -10 0 -1 …
3 5 7 9 11
0 0 0 0 0
5 7 9 11 13
-10 0 4 0 0
7 9 11 13 15
0 0 0 0 0
9 11 13 15 17
-1 0 0 0 0
…
…
‘Q can be well compressed due to redundant
elements’
32
JPEG Encoding
• Compression
 Quantized values are read from the matrix and redundant
0s are removed.
 To cluster the 0s together, the matrix is read diagonally
in an zigzag fashion. The reason is if the matrix doesn’t
have fine changes, the bottom right corner of the matrix
is all 0s.
 JPEG usually uses lossless run-length encoding at the
compression phase.

33
JPEG Encoding

34
JPEG Encoding

8x8
pixel
block

Discrete
Cosine
Transform

Quantization

Run Length,
Huffman
Encoding

to .jpg file

35
MPEG Encoding
Used to compress video.
 Basic idea:


 Each video is a rapid sequence of a set of frames. Each
frame is a spatial combination of pixels, or a picture.
 Compressing video =
spatially compressing each frame
+
temporally compressing a set of frames.

36
MPEG Encoding
• Spatial Compression
 Each frame is spatially compressed by JPEG.
• Temporal Compression
 Redundant frames are removed.
 Usually little difference from one to the next frame
is suitable for compression.
{For example, in a static scene in which someone is
talking, most frames are the same except for the
segment around the speaker’s lips, which changes
from one frame to the next}.
 Three frames: I, P, B.
37
MPEG Encoding
• I (intra-picture) frame: Just a JPEG encoded
image.
• P (predicted) frame: Encoded by computing
the differences between a current and a
previous frame.
• B (bidirectional) frame: Similar to P-frame
except that it is interpolated between previous
and future frame.
38
MPEG Encoding
• order in which to transmit: I – P – I
P is sandwiched between groups of B
P is the difference from the previous I-frame
B is interpolated from the nearest I and P
order in which to display I – B – B – P – B – B – I

39
Thank You
40

More Related Content

What's hot

Introduction for Data Compression
Introduction for Data Compression Introduction for Data Compression
Introduction for Data Compression MANISH T I
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Project Student
 
Data Compression Project Presentation
Data Compression Project PresentationData Compression Project Presentation
Data Compression Project PresentationMyuran Kanga, MS, MBA
 
data compression technique
data compression techniquedata compression technique
data compression techniqueCHINMOY PAUL
 
Compression of digital voice and video
Compression of digital voice and videoCompression of digital voice and video
Compression of digital voice and videosangusajjan
 
Data compression introduction
Data compression introductionData compression introduction
Data compression introductionRahul Khanwani
 
Video compression
Video compressionVideo compression
Video compressionDarkNight14
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compressionasodariyabhavesh
 
Steganography presentation
Steganography presentationSteganography presentation
Steganography presentationBSheghembe
 
Lossless Compression
Lossless CompressionLossless Compression
Lossless CompressionPuchpa Oks
 
Audio compression 1
Audio compression 1Audio compression 1
Audio compression 1Rajat Kumar
 
Chapter 5 - Data Compression
Chapter 5 - Data CompressionChapter 5 - Data Compression
Chapter 5 - Data CompressionPratik Pradhan
 
Image compression standards
Image compression standardsImage compression standards
Image compression standardskirupasuchi1996
 

What's hot (20)

Introduction for Data Compression
Introduction for Data Compression Introduction for Data Compression
Introduction for Data Compression
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)
 
Data Compression Project Presentation
Data Compression Project PresentationData Compression Project Presentation
Data Compression Project Presentation
 
data compression technique
data compression techniquedata compression technique
data compression technique
 
Compression of digital voice and video
Compression of digital voice and videoCompression of digital voice and video
Compression of digital voice and video
 
Compression techniques
Compression techniquesCompression techniques
Compression techniques
 
Data compression introduction
Data compression introductionData compression introduction
Data compression introduction
 
Video compression
Video compressionVideo compression
Video compression
 
Multimedia compression
Multimedia compressionMultimedia compression
Multimedia compression
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compression
 
Steganography presentation
Steganography presentationSteganography presentation
Steganography presentation
 
data compression.
data compression.data compression.
data compression.
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
 
Audio compression
Audio compressionAudio compression
Audio compression
 
Lzw
LzwLzw
Lzw
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Lossless Compression
Lossless CompressionLossless Compression
Lossless Compression
 
Audio compression 1
Audio compression 1Audio compression 1
Audio compression 1
 
Chapter 5 - Data Compression
Chapter 5 - Data CompressionChapter 5 - Data Compression
Chapter 5 - Data Compression
 
Image compression standards
Image compression standardsImage compression standards
Image compression standards
 

Viewers also liked

Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Techniquenayakslideshare
 
4 data compression
4 data compression4 data compression
4 data compressionRejin Thomas
 
G zip compresser ppt
G zip compresser pptG zip compresser ppt
G zip compresser pptgaurav kumar
 
Data compression
Data compressionData compression
Data compressionNizar Sbaih
 
Data Compression In SQL
Data Compression In SQLData Compression In SQL
Data Compression In SQLBoosh Booshan
 
Text compression in LZW and Flate
Text compression in LZW and FlateText compression in LZW and Flate
Text compression in LZW and FlateSubeer Rangra
 
Spandana image processing and compression techniques (7840228)
Spandana   image processing and compression techniques (7840228)Spandana   image processing and compression techniques (7840228)
Spandana image processing and compression techniques (7840228)indianspandana
 
A new algorithm for data compression technique using vlsi
A new algorithm for data compression technique using vlsiA new algorithm for data compression technique using vlsi
A new algorithm for data compression technique using vlsiTejeswar Tej
 
Image compression
Image compressionImage compression
Image compressionAle Johnsan
 
Data compression in Modern Application
Data compression in Modern ApplicationData compression in Modern Application
Data compression in Modern ApplicationLivePerson
 
Evm Test Impairements
Evm Test ImpairementsEvm Test Impairements
Evm Test Impairementschiportal
 
An Implementation of Quadtree for Image Compression
An Implementation of Quadtree for Image CompressionAn Implementation of Quadtree for Image Compression
An Implementation of Quadtree for Image CompressionMohammad Shaker
 
Adaptive Huffman and Lossless Compression Techniques - Documentation
Adaptive Huffman and Lossless Compression Techniques - DocumentationAdaptive Huffman and Lossless Compression Techniques - Documentation
Adaptive Huffman and Lossless Compression Techniques - DocumentationMohammad Shaker
 
Computer software 2
Computer software 2Computer software 2
Computer software 2Suresh Kumar
 

Viewers also liked (15)

Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Technique
 
4 data compression
4 data compression4 data compression
4 data compression
 
Compression
CompressionCompression
Compression
 
G zip compresser ppt
G zip compresser pptG zip compresser ppt
G zip compresser ppt
 
Data compression
Data compressionData compression
Data compression
 
Data Compression In SQL
Data Compression In SQLData Compression In SQL
Data Compression In SQL
 
Text compression in LZW and Flate
Text compression in LZW and FlateText compression in LZW and Flate
Text compression in LZW and Flate
 
Spandana image processing and compression techniques (7840228)
Spandana   image processing and compression techniques (7840228)Spandana   image processing and compression techniques (7840228)
Spandana image processing and compression techniques (7840228)
 
A new algorithm for data compression technique using vlsi
A new algorithm for data compression technique using vlsiA new algorithm for data compression technique using vlsi
A new algorithm for data compression technique using vlsi
 
Image compression
Image compressionImage compression
Image compression
 
Data compression in Modern Application
Data compression in Modern ApplicationData compression in Modern Application
Data compression in Modern Application
 
Evm Test Impairements
Evm Test ImpairementsEvm Test Impairements
Evm Test Impairements
 
An Implementation of Quadtree for Image Compression
An Implementation of Quadtree for Image CompressionAn Implementation of Quadtree for Image Compression
An Implementation of Quadtree for Image Compression
 
Adaptive Huffman and Lossless Compression Techniques - Documentation
Adaptive Huffman and Lossless Compression Techniques - DocumentationAdaptive Huffman and Lossless Compression Techniques - Documentation
Adaptive Huffman and Lossless Compression Techniques - Documentation
 
Computer software 2
Computer software 2Computer software 2
Computer software 2
 

Similar to Data compression

image basics and image compression
image basics and image compressionimage basics and image compression
image basics and image compressionmurugan hari
 
lossy compression JPEG
lossy compression JPEGlossy compression JPEG
lossy compression JPEGMahmoud Hikmet
 
notes_Image Compression_edited.ppt
notes_Image Compression_edited.pptnotes_Image Compression_edited.ppt
notes_Image Compression_edited.pptHarisMasood20
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.pptnaghamallella
 
CyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfCyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfMohammadAzreeYahaya
 
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIX
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIXSQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIX
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIXijcsit
 
Compression: Images (JPEG)
Compression: Images (JPEG)Compression: Images (JPEG)
Compression: Images (JPEG)danishrafiq
 
image compression in data compression
image compression in data compressionimage compression in data compression
image compression in data compressionZaabir Ali
 
Why Image compression is Necessary?
Why Image compression is Necessary?Why Image compression is Necessary?
Why Image compression is Necessary?Prabhat Kumar
 
SOC Application Studies: Image Compression
SOC Application Studies: Image CompressionSOC Application Studies: Image Compression
SOC Application Studies: Image CompressionA B Shinde
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image CompressionMathankumar S
 
Multimedia image compression standards
Multimedia image compression standardsMultimedia image compression standards
Multimedia image compression standardsMazin Alwaaly
 

Similar to Data compression (20)

image basics and image compression
image basics and image compressionimage basics and image compression
image basics and image compression
 
lossy compression JPEG
lossy compression JPEGlossy compression JPEG
lossy compression JPEG
 
notes_Image Compression_edited.ppt
notes_Image Compression_edited.pptnotes_Image Compression_edited.ppt
notes_Image Compression_edited.ppt
 
Source coding
Source codingSource coding
Source coding
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.ppt
 
Jpeg compression
Jpeg compressionJpeg compression
Jpeg compression
 
CyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfCyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdf
 
Squashed JPEG Image Compression via Sparse Matrix
Squashed JPEG Image Compression via Sparse MatrixSquashed JPEG Image Compression via Sparse Matrix
Squashed JPEG Image Compression via Sparse Matrix
 
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIX
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIXSQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIX
SQUASHED JPEG IMAGE COMPRESSION VIA SPARSE MATRIX
 
Squashed JPEG Image Compression via Sparse Matrix
Squashed JPEG Image Compression via Sparse MatrixSquashed JPEG Image Compression via Sparse Matrix
Squashed JPEG Image Compression via Sparse Matrix
 
Compression: Images (JPEG)
Compression: Images (JPEG)Compression: Images (JPEG)
Compression: Images (JPEG)
 
Image compression and jpeg
Image compression and jpegImage compression and jpeg
Image compression and jpeg
 
image compression in data compression
image compression in data compressionimage compression in data compression
image compression in data compression
 
Why Image compression is Necessary?
Why Image compression is Necessary?Why Image compression is Necessary?
Why Image compression is Necessary?
 
Data Compression
Data CompressionData Compression
Data Compression
 
SOC Application Studies: Image Compression
SOC Application Studies: Image CompressionSOC Application Studies: Image Compression
SOC Application Studies: Image Compression
 
Jpeg
JpegJpeg
Jpeg
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image Compression
 
Multimedia image compression standards
Multimedia image compression standardsMultimedia image compression standards
Multimedia image compression standards
 

Recently uploaded

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 

Recently uploaded (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Data compression

  • 1. Data Compression Presented to: Prof. Dr. Maha Sharkas presented by: Sherif Mohamed 1
  • 2. Data Compression Outline 1) 2) 3) 4) 5) 6) Introduction. Types of Data Compression. Lossless Compression. Lossless Algorithms. Lossy Compression. Lossy Algorithms . 2
  • 3. Data Compression • It is the process of reducing the amount of data required to represent a given quantity of information. • Save time and help to optimize resources i. In sending data over communication line: less time to transmit and less storage to host. • Reduce length of data transmission time over the network. 3
  • 4. Types of Data Compression 1. Lossless Compression. 2. Lossy Compression. 4
  • 5. Data Compression Algorithm • Lossless Compression If the compressed data is reconstructed and the original data is obtain without any loss of information then this technique is called lossless compression. 5
  • 6. Types of Data Compression • Lossy Compression If the compressed data is reconstructed and the approximation of original data is obtain and loss of information occurs then this technique is called lossy compression. The original message can never be recovered exactly as it was before it was compressed. 6
  • 7. Types of Data Compression Lossless Original Data Compressed Data Original Data Approximated 7
  • 9. Lossless Algorithm • Huffman Encoding  There’s no unique Huffman code.  Algorithm: ① ② ③ Make a leaf node for each code symbol Add the generation probability of each symbol to the leaf node Take the two leaf nodes with the smallest probability and connect them into a new node Add 1 or 0 to each of the two branches The probability of the new node is the sum of the probabilities of the two connecting nodes If there is only one node left, the code construction is completed. If not, go back to (2) 9
  • 12. Lossless Algorithm • Lempel Ziv Walsh (LZW) Encoding • It is dictionary based encoding • Basic idea:  Create a dictionary or a code table of strings used during communication.  If both sender and receiver have a copy of the dictionary, then previously-encountered strings can be substituted by their index in the dictionary. • LZW to compress text, executable code and similar data files to about one half their original size. 12
  • 13. LZW Coding  Have 2 phases:  Building an indexed dictionary  Compressing a string of symbols • Algorithm:  Extract the smallest substring that cannot be found in the remaining uncompressed string.  Store that substring in the dictionary as a new entry and assign it an index value  Substring is replaced with the index found in the dictionary  Insert the index and the last character of the substring into the compressed string 13
  • 14. LZW Coding • Lempel Ziv Compression 14
  • 15. 15
  • 16. LZW Coding • Lempel Ziv Decompression 16
  • 17. 17
  • 18. Lossless Algorithm • Run Length Encoding • Simplest method of compression. • Replace consecutive repeating occurrences of a symbol by 1 occurrence of the symbol itself, then followed by the number of occurrences. 18
  • 19. Run Length Coding • The method can be more efficient if the data uses only 2 symbols (0s and 1s) in bit patterns and 1 symbol is more frequent than another. 19
  • 20. Lossy Algorithm • Used for compressing images and video files (our eyes cannot distinguish subtle changes, so lossy data is acceptable). • These methods are cheaper, less time and space. • Several methods:  JPEG: compress pictures and graphics  MPEG: compress video  MP3: compress audio 20
  • 21. Lossy Algorithm • JPEG Encoding • Used to compress pictures and graphics. • In JPEG, a grayscale picture is divided into 8x8 pixel blocks to decrease the number of calculations. • Basic idea:  Change the picture into a linear (vector) sets of numbers that reveals the redundancies.  The redundancies is then removed by one of lossless 21
  • 23. JPEG Encoding • DCT(Discrete Cosine Transform) • Image is divided into blocks of 8*8 pixels. • For grey-scale images, pixel is represented by 8-bits. • For color images, pixel is represented by 24-bits or three 8-bit groups. 23
  • 24. JPEG Encoding • DCT takes an 8*8 matrix and produces another 8*8 matrix and its values represent by this equation: T[i][j] = 0.25 C(i) C(j) ∑ ∑ P[x][y] Cos(2x+1)iπ/16 * Cos (2y+1)jπ/16  i = 0, 1, …7, j = 0, 1, …7  C(i) = 1/√2, i =0 = 1 otherwise T contains values called ‘Spatial frequencies’ 24
  • 25. JPEG Encoding • T[0][0] is called the DC coefficient, related to average values in the array, Cos 0 = 1 • Other values of T are called AC coefficients, cosine functions of higher frequencies  Case 1: all P’s are same, image of single color with no variation at all, AC coefficients are all zeros.  Case 2: little variation in P’s, many, not all, AC coefficients are zeros.  Case 3: large variation in P’s, a few AC coefficients are zeros. 25
  • 27. JPEG Encoding P-matrix T-matrix • 20 30 40 50 60 … 720 -182 0 -19 0 … 30 40 50 60 70 -182 0 0 0 0 40 50 60 70 80 0 0 0 0 0 50 60 70 80 90 -19 0 0 0 0 60 70 80 90 100 0 0 0 0 0 … … ‘Uniform color change and little fine detail, easier to compress after DCT’ 27
  • 28. JPEG Encoding P-matrix T-matrix • 100 150 50 100 100 … 835 15 -17 59 5… 200 10 110 20 200 46 -60 -36 11 14 10 200 130 30 200 -32 -9 130 105 -37 100 10 90 190 120 59 -3 27 -12 30 10 200 200 120 90 50 -71 -24 -56 -40 …. …. ‘Large color change, difficult to compress after DCT’ 28
  • 29. JPEG Encoding • Quantization • Provides an way of ignoring small differences in an image that may not be perceptible. • Another array Q is obtained by dividing each element of T by some number and rounding-off to nearest integer ( The loss is occur in this step) 29
  • 30. JPEG Encoding T-matrix Q-matrix • 152 0 -48 0 -8… 15 0 -5 0 -1… 0 0 0 0 0 0 0 0 0 0 -48 0 38 0 -3 -5 0 4 0 0 0 0 0 0 0 0 0 0 0 0 -8 0 -3 0 13 -1 0 0 0 1 … … ‘Divide by 10 and round-off ’ . 30
  • 31. JPEG Encoding • Dividing T-elements by the same number is not practical, may result in too much loss. • Retain the effects of lower frequencies as much as possible. • To define a quantization array Q, then Q[i][j] = Round (T[i][j] ÷ U[i][j]), i = 0, 1,.........7, j = 0, 1, …7 31
  • 32. JPEG Encoding • U = 1 3 5 7 9… Q= 152 0 -10 0 -1 … 3 5 7 9 11 0 0 0 0 0 5 7 9 11 13 -10 0 4 0 0 7 9 11 13 15 0 0 0 0 0 9 11 13 15 17 -1 0 0 0 0 … … ‘Q can be well compressed due to redundant elements’ 32
  • 33. JPEG Encoding • Compression  Quantized values are read from the matrix and redundant 0s are removed.  To cluster the 0s together, the matrix is read diagonally in an zigzag fashion. The reason is if the matrix doesn’t have fine changes, the bottom right corner of the matrix is all 0s.  JPEG usually uses lossless run-length encoding at the compression phase. 33
  • 36. MPEG Encoding Used to compress video.  Basic idea:   Each video is a rapid sequence of a set of frames. Each frame is a spatial combination of pixels, or a picture.  Compressing video = spatially compressing each frame + temporally compressing a set of frames. 36
  • 37. MPEG Encoding • Spatial Compression  Each frame is spatially compressed by JPEG. • Temporal Compression  Redundant frames are removed.  Usually little difference from one to the next frame is suitable for compression. {For example, in a static scene in which someone is talking, most frames are the same except for the segment around the speaker’s lips, which changes from one frame to the next}.  Three frames: I, P, B. 37
  • 38. MPEG Encoding • I (intra-picture) frame: Just a JPEG encoded image. • P (predicted) frame: Encoded by computing the differences between a current and a previous frame. • B (bidirectional) frame: Similar to P-frame except that it is interpolated between previous and future frame. 38
  • 39. MPEG Encoding • order in which to transmit: I – P – I P is sandwiched between groups of B P is the difference from the previous I-frame B is interpolated from the nearest I and P order in which to display I – B – B – P – B – B – I 39