October 8th, 2002, 06:34 AM
im wondering if anyone knows the basics of LZW compression and can give me some sample code (in c) of LZW in its most simple form (both encoding and decoding). im trying to get a handle on how it works but all the code i find is quite complex, i need something simple to get me started.
October 8th, 2002, 01:02 PM
LZW is not too hard. But you really should not learn from the code how it works. Code implementations are made for machines to read, not for humans. They probably contain many optimizations (eg. for speed) which make them hard to be read.
The algorithm behind it is afaik "Huffman"-encoding, this is what you should read some theory about. (www.google.com)
Try to think of a book. In English afaik the letters "e" and "a" are used the most.
In standard ASCII representation any letter uses 8 bits. Why not use only one bit for "e" and "a" like e=0 and a=1? YouŽll save a lot of space then...
The algorithm afaik sorts all letters (any codes, not only letters) by their frequency and puts it into a table (the "key" if you see huffmann as a en/decoding algorithm).
then the most often used one gets the shortest number of bits.
do you understand what i want to say?
October 9th, 2002, 06:41 PM