SlideShare a Scribd company logo
1 of 15
LZW Encoding Algorithm
By
Israa A. Basheer
Rasha A. Yousef
Maalem A. Atiyaa
Supervised By
Assist. Prof. Wisam D. Abdullah
TIKRIT UNIVERSITY
COLLEGE OF COMPUTERSCIENCE
ANDMATHEMATICS
POSTGRADUATE
Introduction To LZW Compression Algorithm
History of LZW algorithm
developed by Abraham Lempel and Jacob Ziv ,
Lempel and Ziv published a series of papers describing
various compression algorithms. Their first algorithm was
published in 1977, hence its name: LZ77. This compression
algorithm maintains its dictionary within the data
themselves.
In 1978, Lempel and Ziv published a second paper outlining
a similar algorithm that is now referred to as LZ78. This
algorithm maintains a separate dictionary.
In 1984 Terry Welch published an improved version of the
LZ78 dictionary coding algorithm developed by Lempel and
Ziv.
2
LZW (Lampel–Ziv-Welch) Definition
It is a lossless ‘dictionary based’ compression algorithm in
which longer fragments of the input text are replaced by
much shorter references to code words stored in the special
set called dictionary.
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”.
It used to reduce the size of files, e.g. for archival or
transmission.
It used by a number of formats , including
GIF, TIFF, PostScript, PDF, Unix Compress, and V.42bis.
Working of the LZW
Algorithm
- The Algorithm is broken down into two parts, the encoding algorithm which
converts the strings into integer codes, and the decoding algorithm which does vice
versa.
- Both the encoder and decoder algorithm has a default table or a code-string pair
dataset that acts as the initial model for both the encoder and the decoder. And
when the algorithm goes on the new integer codes for the various string patterns
get added to this table.
- The Encoding 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.
3
Continue…
Algorithm
- 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.
4
Implementation :
The idea of the compression algorithm is the
following:
As the input data is being processed, a
dictionary keeps a correspondence between the
longest encountered words and a list of code
values. The words are replaced by their
corresponding codes and so the input file is
compressed. Therefore, the efficiency of the
algorithm increases as the number of long,
repetitive words in the input data increases.
5
* PSEUDOCODE (For Viewing):
1 Initialize table with single character
strings
2 P = first input character
3 WHILE not end of input stream
4 C = next input character
5 IF P + C is in the string table
6 P = P + C
7 ELSE
8 output the code for P
9 add P + C to the string table
10 P = C
11 END WHILE
12 output code for P
Use the LZW algorithm to compress
the string : BABAABAAA
6
Example Of LZW Compression
Example of LZW Compressiom : Step 1
7
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
BABAABAAA P=empty
C=B
P=p+c
P=c
Example of LZW Compressiom : Step 2
8
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
65 A 257 AB
BABAABAAA P=B
C=A
Example of LZW Compressiom : Step 3
9
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
65 A 257 AB
256 BA 258 BAA
BABAABAAA P=A
C= B
Example of LZW Compressiom : Step 4
10
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
65 A 257 AB
256 BA 258 BAA
257 AB 259 ABA
BABAABAAA P=A
C= A
Example of LZW Compressiom : Step 5
11
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
65 A 257 AB
256 BA 258 BAA
257 AB 259 ABA
65 A 260 AA
BABAABAAA P=A
C= A
Example of LZW Compressiom : Step 6
12
ENCODER OUTPUT STRING TABLE
Output code Representing Codeword String
66 B 256 BA
65 A 257 AB
256 BA 258 BAA
257 AB 259 ABA
65 A 260 AA
260 AA
BABAABAAA P=AA
C= empty
Advantage Of LZW :
1- The LZW is simple, easy and requires no prior information about
the input data stream.
2- The LZW algorithm is faster compared to the other algorithms.
3- The LZW algorithm works more efficiently for files containing lots of
repetitive data.
4-The LZW algorithm compresses the data in a single pass.
5-This is a lossless compression technique, none of the contents in the file
are lost during or after compression.
13
Disadvantage Of LZW :
1- LZW is a fairly old compression technique. All recent computer
systems have the powerful to use more efficient algorithms.
2- Creates entries in the dictionary that may never be used.
3- Useful only for large amount of text data when redundancy is high.
4- Royalties have to be paid to use LZW compression algorithms within
applications.
14
15
THANKS FOR ATTENTION

More Related Content

What's hot

INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionPHI Learning Pvt. Ltd.
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsingkunj desai
 
Image Steganography using LSB
Image Steganography using LSBImage Steganography using LSB
Image Steganography using LSBSreelekshmi Sree
 
Image Steganography using MATLAB
Image Steganography using MATLABImage Steganography using MATLAB
Image Steganography using MATLABVijayMaheshwari12
 
Trible data encryption standard (3DES)
Trible data encryption standard (3DES)Trible data encryption standard (3DES)
Trible data encryption standard (3DES)Ahmed Mohamed Mahmoud
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and DynamicSneh Pahilwani
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algorithamRahul Khanwani
 
multiplexer 4 input
multiplexer 4 inputmultiplexer 4 input
multiplexer 4 inputAnkit Mistry
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSAaritraranjan
 
Information and network security 13 playfair cipher
Information and network security 13 playfair cipherInformation and network security 13 playfair cipher
Information and network security 13 playfair cipherVaibhav Khanna
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithmsRashmi Burugupalli
 
DES (Data Encryption Standard) pressentation
DES (Data Encryption Standard) pressentationDES (Data Encryption Standard) pressentation
DES (Data Encryption Standard) pressentationsarhadisoftengg
 

What's hot (20)

Cryptography
CryptographyCryptography
Cryptography
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third Edition
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Des
DesDes
Des
 
Compiler1
Compiler1Compiler1
Compiler1
 
Image Steganography using LSB
Image Steganography using LSBImage Steganography using LSB
Image Steganography using LSB
 
Image Steganography using MATLAB
Image Steganography using MATLABImage Steganography using MATLAB
Image Steganography using MATLAB
 
Trible data encryption standard (3DES)
Trible data encryption standard (3DES)Trible data encryption standard (3DES)
Trible data encryption standard (3DES)
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and Dynamic
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algoritham
 
multiplexer 4 input
multiplexer 4 inputmultiplexer 4 input
multiplexer 4 input
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
 
RSA Algorithm
RSA AlgorithmRSA Algorithm
RSA Algorithm
 
Information and network security 13 playfair cipher
Information and network security 13 playfair cipherInformation and network security 13 playfair cipher
Information and network security 13 playfair cipher
 
cryptography
cryptographycryptography
cryptography
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
 
DES (Data Encryption Standard) pressentation
DES (Data Encryption Standard) pressentationDES (Data Encryption Standard) pressentation
DES (Data Encryption Standard) pressentation
 
DES
DESDES
DES
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 

Similar to 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 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
 
Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Techniquenayakslideshare
 
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
 
111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.pptAllamJayaPrakash
 
111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.pptAllamJayaPrakash
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptMuhammad Sikandar Mustafa
 
Chapter 4 Lossless Compression Algorithims.pptx
Chapter 4 Lossless Compression Algorithims.pptxChapter 4 Lossless Compression Algorithims.pptx
Chapter 4 Lossless Compression Algorithims.pptxMedinaBedru
 
Improving data compression ratio by the use of optimality of lzw & adaptive h...
Improving data compression ratio by the use of optimality of lzw & adaptive h...Improving data compression ratio by the use of optimality of lzw & adaptive h...
Improving data compression ratio by the use of optimality of lzw & adaptive h...ijitjournal
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - ISHREEHARI WADAWADAGI
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
LZ77 and LZ78 Compression Algorithms
LZ77 and LZ78 Compression AlgorithmsLZ77 and LZ78 Compression Algorithms
LZ77 and LZ78 Compression AlgorithmsMustafa GÖKÇE
 

Similar to LZW Presentation.pptx (20)

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
 
Dictor
DictorDictor
Dictor
 
lempel_ziv
lempel_zivlempel_ziv
lempel_ziv
 
Data Compression Technique
Data Compression TechniqueData Compression Technique
Data Compression Technique
 
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...
 
111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt
 
111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt111111111111111111111111111111111789.ppt
111111111111111111111111111111111789.ppt
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Lossless
LosslessLossless
Lossless
 
Lossless
LosslessLossless
Lossless
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
Chapter 4 Lossless Compression Algorithims.pptx
Chapter 4 Lossless Compression Algorithims.pptxChapter 4 Lossless Compression Algorithims.pptx
Chapter 4 Lossless Compression Algorithims.pptx
 
Text compression
Text compressionText compression
Text compression
 
Improving data compression ratio by the use of optimality of lzw & adaptive h...
Improving data compression ratio by the use of optimality of lzw & adaptive h...Improving data compression ratio by the use of optimality of lzw & adaptive h...
Improving data compression ratio by the use of optimality of lzw & adaptive h...
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - I
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
LZ77 and LZ78 Compression Algorithms
LZ77 and LZ78 Compression AlgorithmsLZ77 and LZ78 Compression Algorithms
LZ77 and LZ78 Compression Algorithms
 

Recently uploaded

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 

Recently uploaded (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 

LZW Presentation.pptx

  • 1. LZW Encoding Algorithm By Israa A. Basheer Rasha A. Yousef Maalem A. Atiyaa Supervised By Assist. Prof. Wisam D. Abdullah TIKRIT UNIVERSITY COLLEGE OF COMPUTERSCIENCE ANDMATHEMATICS POSTGRADUATE
  • 2. Introduction To LZW Compression Algorithm History of LZW algorithm developed by Abraham Lempel and Jacob Ziv , Lempel and Ziv published a series of papers describing various compression algorithms. Their first algorithm was published in 1977, hence its name: LZ77. This compression algorithm maintains its dictionary within the data themselves. In 1978, Lempel and Ziv published a second paper outlining a similar algorithm that is now referred to as LZ78. This algorithm maintains a separate dictionary. In 1984 Terry Welch published an improved version of the LZ78 dictionary coding algorithm developed by Lempel and Ziv. 2 LZW (Lampel–Ziv-Welch) Definition It is a lossless ‘dictionary based’ compression algorithm in which longer fragments of the input text are replaced by much shorter references to code words stored in the special set called dictionary. 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”. It used to reduce the size of files, e.g. for archival or transmission. It used by a number of formats , including GIF, TIFF, PostScript, PDF, Unix Compress, and V.42bis.
  • 3. Working of the LZW Algorithm - The Algorithm is broken down into two parts, the encoding algorithm which converts the strings into integer codes, and the decoding algorithm which does vice versa. - Both the encoder and decoder algorithm has a default table or a code-string pair dataset that acts as the initial model for both the encoder and the decoder. And when the algorithm goes on the new integer codes for the various string patterns get added to this table. - The Encoding 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. 3
  • 4. Continue… Algorithm - 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. 4
  • 5. Implementation : The idea of the compression algorithm is the following: As the input data is being processed, a dictionary keeps a correspondence between the longest encountered words and a list of code values. The words are replaced by their corresponding codes and so the input file is compressed. Therefore, the efficiency of the algorithm increases as the number of long, repetitive words in the input data increases. 5 * PSEUDOCODE (For Viewing): 1 Initialize table with single character strings 2 P = first input character 3 WHILE not end of input stream 4 C = next input character 5 IF P + C is in the string table 6 P = P + C 7 ELSE 8 output the code for P 9 add P + C to the string table 10 P = C 11 END WHILE 12 output code for P
  • 6. Use the LZW algorithm to compress the string : BABAABAAA 6 Example Of LZW Compression
  • 7. Example of LZW Compressiom : Step 1 7 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA BABAABAAA P=empty C=B P=p+c P=c
  • 8. Example of LZW Compressiom : Step 2 8 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA 65 A 257 AB BABAABAAA P=B C=A
  • 9. Example of LZW Compressiom : Step 3 9 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA 65 A 257 AB 256 BA 258 BAA BABAABAAA P=A C= B
  • 10. Example of LZW Compressiom : Step 4 10 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA 65 A 257 AB 256 BA 258 BAA 257 AB 259 ABA BABAABAAA P=A C= A
  • 11. Example of LZW Compressiom : Step 5 11 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA 65 A 257 AB 256 BA 258 BAA 257 AB 259 ABA 65 A 260 AA BABAABAAA P=A C= A
  • 12. Example of LZW Compressiom : Step 6 12 ENCODER OUTPUT STRING TABLE Output code Representing Codeword String 66 B 256 BA 65 A 257 AB 256 BA 258 BAA 257 AB 259 ABA 65 A 260 AA 260 AA BABAABAAA P=AA C= empty
  • 13. Advantage Of LZW : 1- The LZW is simple, easy and requires no prior information about the input data stream. 2- The LZW algorithm is faster compared to the other algorithms. 3- The LZW algorithm works more efficiently for files containing lots of repetitive data. 4-The LZW algorithm compresses the data in a single pass. 5-This is a lossless compression technique, none of the contents in the file are lost during or after compression. 13
  • 14. Disadvantage Of LZW : 1- LZW is a fairly old compression technique. All recent computer systems have the powerful to use more efficient algorithms. 2- Creates entries in the dictionary that may never be used. 3- Useful only for large amount of text data when redundancy is high. 4- Royalties have to be paid to use LZW compression algorithms within applications. 14