SlideShare a Scribd company logo
1 of 19
LZW
Compression
Compression:
 It is a process of reducing size by encoding it’s information
more efficiently.
 Due to this there is a reduction in the number of bits and bytes
used to store the information.
 A smaller file size is generated in order to achieve a faster
transmission of electronic files and a smaller space required
for its downloading.
LZW compression:
 LZW is the first letter of the names of the scientists Abraham
Lempel, Jakob Ziv, and Terry Welch, who developed this
algorithm.
 Is a lossless compression algorithm.
 It is simple and is dictionary based.
Working of LZW compression:
 It is a simple process.
 It replaces strings of characters with single codes.
 A new string of characters is added every time it sees to a
table of strings.
 Compression occurs when a single code is output instead of a
string of characters.
 The first 256 codes are by default assigned to the standard
character set.
Continue…
 Starts with a dictionary of all the single characters and
gradually builds the dictionary as the information is sent
through.
 Lossless compression hence works good for text compression.
 Uses a code table with 4096 as a common choice for number
entries.
Why to use LZW compression:
 Two reasons . . .
 For most palette color images LZW yields the highest
compression efficiency without sacrificing image data.
 The GIF image file format is the de facto standard for images
on the web. Most GIF files use the LZW compression.
LZW Algorithm:
 The LZW Compression Algorithm can summarised as follows:
w = NIL;
while ( read a character k )
{
if wk exists in the dictionary
w = wk;
else
add wk to the dictionary;
output the code for w;
w = k;
}
LZW Encoding:
 If the message to be encoded consists of only one character,
LZW outputs the code for this character; otherwise it inserts
two-or multi-character, overlapping.
 The last character of a pattern is the first character of the next
pattern.
LZW Encoding algorithm:
 Prefix←first input character;
CodeWord←256;
while(not end of character stream)
{ Char← next input character;
if(Prefix+ Char exists in the Dictionary)
Prefix ←Prefix + Char;
Else
{
Output : the code for Prefix;
insertInDictionary( (CodeWord, Prefix + Char) ) ;
CodeWord++;
Prefix←Char;
}
}
Example:
LZW Decoding:
 The LZW decompressor creates the same string table during
decompression.
 Initialize Dictionary with 256 ASCII codes and corresponding
single character strings as their translations.
LZW Decoding algorithm:
 output: string(firstCodeWord);
while(there are more CodeWords)
{
If(Current code word is in the dictionary)
Output: String(Current Code Word);
Else
Ouput: PreviousOutput+Previous Output First character;
Insert in the dictionary: Previous output+ current output First
character.
}
Example:
Advantages :
 This is a lossless compression technique, none of the contents
in the file are lost during or after compression.
 LZW algorithm is efficient because it does not need to pass the
string table to the decompression code.
 The table can be recreated as it was during compression, using
the input stream as data. This avoids insertion of large string
translation table with the compression data.
Disadvantages:
 What happens when the dictionary becomes too large?
 One approach is to throw the dictionary away when it reaches
a certain size.
 Useful only for large amount of text data when redundancy is
high.
Applications:
 A large English text file can typically be compressed via LZW
to about half its original size.
 LZW became very widely used when it became part of
the GIF image format in 1987. It may also (optionally) be used
in TIFF and PDF files.
Lzw compression

More Related Content

What's hot

Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
James Wong
 

What's hot (20)

Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Adaptive Huffman Coding
Adaptive Huffman CodingAdaptive Huffman Coding
Adaptive Huffman Coding
 
Hash mac algorithms
Hash mac algorithmsHash mac algorithms
Hash mac algorithms
 
Hash Function
Hash FunctionHash Function
Hash Function
 
Hash function
Hash functionHash function
Hash function
 
Video Compression Techniques
Video Compression TechniquesVideo Compression Techniques
Video Compression Techniques
 
Encryption algorithms
Encryption algorithmsEncryption algorithms
Encryption algorithms
 
Multimedia:Multimedia compression
Multimedia:Multimedia compression Multimedia:Multimedia compression
Multimedia:Multimedia compression
 
Data Redundacy
Data RedundacyData Redundacy
Data Redundacy
 
Lzw coding technique for image compression
Lzw coding technique for image compressionLzw coding technique for image compression
Lzw coding technique for image compression
 
Data compression
Data  compressionData  compression
Data compression
 
Columnar transposition cipher
Columnar transposition cipherColumnar transposition cipher
Columnar transposition cipher
 
Data compression
Data compressionData compression
Data compression
 
Deep learning presentation
Deep learning presentationDeep learning presentation
Deep learning presentation
 
Lossless Compression
Lossless CompressionLossless Compression
Lossless Compression
 
Cryptography - Block cipher & stream cipher
Cryptography - Block cipher & stream cipherCryptography - Block cipher & stream cipher
Cryptography - Block cipher & stream cipher
 
Text compression
Text compressionText compression
Text compression
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
lecture on data compression
lecture on data compressionlecture on data compression
lecture on data compression
 
Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash function
 

Similar to Lzw compression

Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffman
chidabdu
 
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
Helan4
 

Similar to Lzw compression (18)

LZW Presentation.pptx
LZW Presentation.pptxLZW Presentation.pptx
LZW Presentation.pptx
 
Design and Implementation of LZW Data Compression Algorithm
Design and Implementation of LZW Data Compression AlgorithmDesign and Implementation of LZW Data Compression Algorithm
Design and Implementation of LZW Data Compression Algorithm
 
Design and Implementation of LZW Data Compression Algorithm
Design and Implementation of LZW Data Compression AlgorithmDesign and Implementation of LZW Data Compression Algorithm
Design and Implementation of LZW Data Compression Algorithm
 
Lossless LZW Data Compression Algorithm on CUDA
Lossless LZW Data Compression Algorithm on CUDALossless LZW Data Compression Algorithm on CUDA
Lossless LZW Data Compression Algorithm on CUDA
 
lempel_ziv
lempel_zivlempel_ziv
lempel_ziv
 
Lossless
LosslessLossless
Lossless
 
Lossless
LosslessLossless
Lossless
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
 
Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Technique
 
Dictor
DictorDictor
Dictor
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
 
Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffman
 
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
2.3 unit-ii-text-compression-a-outline-compression-techniques-run-length-codi...
 
Assem -lect-6
Assem -lect-6Assem -lect-6
Assem -lect-6
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 
Data Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression methodData Communication & Computer Networks : LZW compression method
Data Communication & Computer Networks : LZW compression method
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Lex & yacc
Lex & yaccLex & yacc
Lex & yacc
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (20)

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 

Lzw compression

  • 2. Compression:  It is a process of reducing size by encoding it’s information more efficiently.  Due to this there is a reduction in the number of bits and bytes used to store the information.  A smaller file size is generated in order to achieve a faster transmission of electronic files and a smaller space required for its downloading.
  • 3. LZW compression:  LZW is the first letter of the names of the scientists Abraham Lempel, Jakob Ziv, and Terry Welch, who developed this algorithm.  Is a lossless compression algorithm.  It is simple and is dictionary based.
  • 4. Working of LZW compression:  It is a simple process.  It replaces strings of characters with single codes.  A new string of characters is added every time it sees to a table of strings.  Compression occurs when a single code is output instead of a string of characters.  The first 256 codes are by default assigned to the standard character set.
  • 5. Continue…  Starts with a dictionary of all the single characters and gradually builds the dictionary as the information is sent through.  Lossless compression hence works good for text compression.  Uses a code table with 4096 as a common choice for number entries.
  • 6. Why to use LZW compression:  Two reasons . . .  For most palette color images LZW yields the highest compression efficiency without sacrificing image data.  The GIF image file format is the de facto standard for images on the web. Most GIF files use the LZW compression.
  • 7. LZW Algorithm:  The LZW Compression Algorithm can summarised as follows: w = NIL; while ( read a character k ) { if wk exists in the dictionary w = wk; else add wk to the dictionary; output the code for w; w = k; }
  • 8. LZW Encoding:  If the message to be encoded consists of only one character, LZW outputs the code for this character; otherwise it inserts two-or multi-character, overlapping.  The last character of a pattern is the first character of the next pattern.
  • 9. LZW Encoding algorithm:  Prefix←first input character; CodeWord←256; while(not end of character stream) { Char← next input character; if(Prefix+ Char exists in the Dictionary) Prefix ←Prefix + Char; Else { Output : the code for Prefix; insertInDictionary( (CodeWord, Prefix + Char) ) ; CodeWord++; Prefix←Char; } }
  • 10.
  • 12. LZW Decoding:  The LZW decompressor creates the same string table during decompression.  Initialize Dictionary with 256 ASCII codes and corresponding single character strings as their translations.
  • 13. LZW Decoding algorithm:  output: string(firstCodeWord); while(there are more CodeWords) { If(Current code word is in the dictionary) Output: String(Current Code Word); Else Ouput: PreviousOutput+Previous Output First character; Insert in the dictionary: Previous output+ current output First character. }
  • 14.
  • 16. Advantages :  This is a lossless compression technique, none of the contents in the file are lost during or after compression.  LZW algorithm is efficient because it does not need to pass the string table to the decompression code.  The table can be recreated as it was during compression, using the input stream as data. This avoids insertion of large string translation table with the compression data.
  • 17. Disadvantages:  What happens when the dictionary becomes too large?  One approach is to throw the dictionary away when it reaches a certain size.  Useful only for large amount of text data when redundancy is high.
  • 18. Applications:  A large English text file can typically be compressed via LZW to about half its original size.  LZW became very widely used when it became part of the GIF image format in 1987. It may also (optionally) be used in TIFF and PDF files.