1

How can the LZW output sequence be improved to achieve higher compression? Are there any specific methods? (I am applying LZW compression on a text file)

user4345738
  • 181
  • 8

2 Answers2

2

LZW is one quite specific compression algorithm, which was a significant milestone in the history of compression algorithms, but more due to its relative simplicity and speed than due to its compression ratio. LZW also has the advantage that it is a single-pass algorithm, making it a good choice for real-time compression in hardware. However, several newer algorithms e.g. Deflate (ZIP) have better compression ratios.

Standard LZW can be tweaked in a number of ways to achieve better compression performance mainly by expanding the size of the dictionary and also by reusing dictionary space occupied by rarely or never used strings, but it's probably a lot easier to just switch to one of the more recent algorithms, like ZIP or BZIP2.

  • thanks for the alternatives but I need to specificly improve the output sequence of LZW to achieve higher compression but I can't find what ways this can be done. – user4345738 Dec 24 '14 at 15:04
  • Expand the dictionary size. What's your maximum code-width now? – 500 - Internal Server Error Dec 24 '14 at 15:05
  • As you know, LZW works by storing strings in a dictionary as they are read and matched from the input and by outputting the index into the dictionary of a matched string. So for a dictionary with room for 4K entries (typical for standard LZW) your maximum output code width is 12 bits. – 500 - Internal Server Error Dec 24 '14 at 15:25
  • I understand thanks! However, one last thing, by expanding the dictionary size do you exactly improve the LZW output sequence? – user4345738 Dec 24 '14 at 16:27
  • It depends what you mean by that. Having a larger dictionary will produce relatively smaller output, but this is assuming there are redundancies in the file that span more than the width of the dictionary. If the file being compressed becomes fundamentally different every 3 or 4 K, there may not be any advantage to the larger dictionary. – 500 - Internal Server Error Dec 25 '14 at 20:36
0

You can try a variable-bit length:http://en.m.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch.

Gigamegs
  • 12,342
  • 7
  • 31
  • 71