SlideShare une entreprise Scribd logo
1  sur  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: Lossless Data Encoding

Contenu connexe

Tendances

Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compressionM.k. Praveen
 
Fundamentals and image compression models
Fundamentals and image compression modelsFundamentals and image compression models
Fundamentals and image compression modelslavanya marichamy
 
Wavelet based image compression technique
Wavelet based image compression techniqueWavelet based image compression technique
Wavelet based image compression techniquePriyanka Pachori
 
comparision of lossy and lossless image compression using various algorithm
comparision of lossy and lossless image compression using various algorithmcomparision of lossy and lossless image compression using various algorithm
comparision of lossy and lossless image compression using various algorithmchezhiyan chezhiyan
 
Video compression
Video compressionVideo compression
Video compressionnnmaurya
 
Image compression: Techniques and Application
Image compression: Techniques and ApplicationImage compression: Techniques and Application
Image compression: Techniques and ApplicationNidhi Baranwal
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compressionanithabalaprabhu
 
Data compression techniques
Data compression techniquesData compression techniques
Data compression techniquesDeep Bhatt
 
Chapter 5 - Data Compression
Chapter 5 - Data CompressionChapter 5 - Data Compression
Chapter 5 - Data CompressionPratik Pradhan
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compressionasodariyabhavesh
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Project Student
 

Tendances (20)

Data compression
Data compressionData compression
Data compression
 
Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compression
 
Fundamentals and image compression models
Fundamentals and image compression modelsFundamentals and image compression models
Fundamentals and image compression models
 
Introduction Data Compression/ Data compression, modelling and coding,Image C...
Introduction Data Compression/ Data compression, modelling and coding,Image C...Introduction Data Compression/ Data compression, modelling and coding,Image C...
Introduction Data Compression/ Data compression, modelling and coding,Image C...
 
Wavelet based image compression technique
Wavelet based image compression techniqueWavelet based image compression technique
Wavelet based image compression technique
 
comparision of lossy and lossless image compression using various algorithm
comparision of lossy and lossless image compression using various algorithmcomparision of lossy and lossless image compression using various algorithm
comparision of lossy and lossless image compression using various algorithm
 
Jpeg compression
Jpeg compressionJpeg compression
Jpeg compression
 
Video compression
Video compressionVideo compression
Video compression
 
Image compression: Techniques and Application
Image compression: Techniques and ApplicationImage compression: Techniques and Application
Image compression: Techniques and Application
 
Image compression .
Image compression .Image compression .
Image compression .
 
JPEG
JPEGJPEG
JPEG
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compression
 
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 techniques
Data compression techniquesData compression techniques
Data compression techniques
 
Noise
NoiseNoise
Noise
 
Chapter 5 - Data Compression
Chapter 5 - Data CompressionChapter 5 - Data Compression
Chapter 5 - Data Compression
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compression
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)
 
Image Compression
Image CompressionImage Compression
Image Compression
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 

Similaire à LZW Compression: Lossless Data Encoding

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 Algorithmijistjournal
 
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 Algorithmijistjournal
 
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 CUDAIOSR Journals
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptographyPrabhat Goel
 
Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Techniquenayakslideshare
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical AnalyzerArchana Gopinath
 
Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffmanchidabdu
 
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
 
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 methodDr Rajiv Srivastava
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellBryan O'Sullivan
 

Similaire à LZW Compression: Lossless Data Encoding (20)

LZW Presentation.pptx
LZW Presentation.pptxLZW Presentation.pptx
LZW Presentation.pptx
 
Lzw
LzwLzw
Lzw
 
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
 
Text compression
Text compressionText compression
Text compression
 
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
 

Dernier

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 

Dernier (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 

LZW Compression: Lossless Data Encoding

  • 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.