Your SlideShare is downloading. ×
0
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Compression project presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Compression project presentation

1,106

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,106
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
53
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. (LZ78Based) LZW Data Compression AlgorithmZEESHAN SAJID 14222MOHSIN ALI 11949MUHAMMAD FAIZAN 12510
  • 2. Table of contents Introduction LZ78 Basic Algorithm LZW Compression LZW Decompression Application and Implementation Conclusion
  • 3. Data compression In computer science and information theory, data compression, source coding, or bit-rate reduction involves encoding information using fewer bits than the original representation. Compression can be either lossy or lossless. Lossless CompressionLossless compression reduces bits by identifying andeliminating statistical redundancy. No information is lost inlossless compression. Lossy CompressionLossy compression reduces bits by identifying marginallyimportant information and removing it. The process ofreducing the size of a data file is popularly referred to as datacompression, although its formal name is source coding (codingdone at the source of the data, before it is stored or transmitted).
  • 4. LZ78 Algorithm Table 1: The encoding process Step Pos Dictionary Output 1. 1 A (0,A) 2. 2 B (0,B) 3. 3 BC (2,C) 4. 5 BCA (3,A) 5. 8 BA (2,A)Pos 1 2 3 4 5 6 7 8 9Char A B B C B C A B A
  • 5. Introduction to LZW Static coding schemes require some knowledge about the data before encoding takes place. Universal coding schemes, like LZW, do not require advance knowledge and can build such knowledge on-the-fly. 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” LZW compression uses a code table, with 4096 as a common choice for the number of table entries.
  • 6. LZW Algorithm LZW is a "dictionary"-based compression algorithm. This means that instead of tabulating character counts and building trees (as for Huffman encoding), LZW encodes data by referencing a dictionary. Thus, to encode a substring, only a single code number, corresponding to that substrings index in the dictionary, needs to be written to the output file.  Lempel & Ziv is the foremost technique for general purpose data compression due to its simplicity and versatility. Typically, you can expect LZW to compress text, executable code, and similar data files to about one-half their original size. LZW also performs well when presented with extremely redundant data files, such as tabulated numbers, computer source code, and acquired signals. Compression ratios of 5:1 are common for these cases. LZW is the basis of several personal computer utilities that claim to"double the capacity of your hard drive."
  • 7. Introduction to LZW (contd) 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. Decoding is achieved by taking each code from the compressed file, and translating it through the code table to find what character or characters it represents.
  • 8. LZW Encoding Algorithm1 Initialize table with single character strings2 P = first input character3 WHILE not end of input stream4 C = next input character5 IF P + C is in the string table6 P=P+C7 ELSE8 output the code for P9 add P + C to the string table10 P=C11 END WHILE12 output code for P
  • 9. Example 1: Compression using LZW Example 1: Use the LZW algorithm to compress the string BABAABAAA
  • 10. Example 1: LZW Compression Step 1BABAABAAA P=A C=emptyENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA
  • 11. Example 1: LZW Compression Step 2BABAABAAA P=B C=emptyENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA65 A 257 AB
  • 12. Example 1: LZW Compression Step 3BABAABAAA P=A C=emptyENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA65 A 257 AB256 BA 258 BAA
  • 13. Example 1: LZW Compression Step 4BABAABAAA P=A C=emptyENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA65 A 257 AB256 BA 258 BAA257 AB 259 ABA
  • 14. Example 1: LZW Compression Step 5BABAABAAA P=A C=AENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA65 A 257 AB256 BA 258 BAA257 AB 259 ABA65 A 260 AA
  • 15. Example 1: LZW Compression Step 6BABAABAAA P=AA C=emptyENCODER OUTPUT STRING TABLEoutput code representing codeword string66 B 256 BA65 A 257 AB256 BA 258 BAA257 AB 259 ABA65 A 260 AA260 AA
  • 16. LZW Decompression The LZW decompressor creates the same string table during decompression. It starts with the first 256 table entries initialized to single characters. The string table is updated for each character in the input stream, except the first one. Decoding achieved by reading codes and translating them through the code table being built.
  • 17. LZW Decompression Algorithm1 Initialize table with single character strings2 OLD = first input code3 output translation of OLD4 WHILE not end of input stream5 NEW = next input code6 IF NEW is not in the string table7 S = translation of OLD8 S=S+C9 ELSE10 S = translation of NEW11 output S12 C = first character of S13 OLD + C to the string table14 OLD = NEW15 END WHILE
  • 18. Example 2: LZW Decompression 1 Example 2: Use LZW to decompress the output sequence of Example 1: <66><65><256><257><65><260>.
  • 19. Example 2: LZW Decompression Step 1<66><65><256><257><65><260> Old = 65 S=A New = 66 C=A ENCODER OUTPUT STRING TABLE string codeword stringBA 256 BA
  • 20. Example 2: LZW Decompression Step 2<66><65><256><257><65><260> Old = 256 S = BA New = 256 C = B ENCODER OUTPUT STRING TABLE string codeword stringBA 256 BABA 257 AB
  • 21. Example 2: LZW Decompression Step 3<66><65><256><257><65><260> Old = 257 S = AB New = 257 C = A ENCODER OUTPUT STRING TABLE string codeword stringBA 256 BABA 257 ABAB 258 BAA
  • 22. Example 2: LZW Decompression Step 4<66><65><256><257><65><260> Old = 65 S = A New = 65 C = A ENCODER OUTPUT STRING TABLE string codeword stringBA 256 BABA 257 ABAB 258 BAAA 259 ABA
  • 23. Example 2: LZW Decompression Step 5<66><65><256><257><65><260> Old = 260 S = AA New = 260 C = A ENCODER OUTPUT STRING TABLE string codeword stringBA 256 BABA 257 ABAB 258 BAAA 259 ABAAA 260 AA
  • 24. Our Application and Implementation
  • 25. GUI of EXE File

×