Home > database >  Image compression and decompression Java
Image compression and decompression Java

Time:11-30

I want to create a program which compresses and decompresses images , there are many algorithms to do that , but I was asked to use the LZSS algorithm to compress and decompress the images , my question is that isn't the LZSS a dictionary type data compression method ? used only for text files ? or am I wrong ? Can the LZSS algorithm be used to compress and decompress images ?

CodePudding user response:

Dictionary-type compression is applicable when there are many repeated sequences of bytes. Equivalently, it's applicable when seeing a byte sequence that you've seen before suggests that the next byte will also match what you saw before.

The same can be said of pretty much all "universal" lossless compression algorithms, which are not designed specifically to compress a certain kind of data, and the LZ algorithms are in this class.

These algorithms compress image data with varying degrees of success, depending on the type of image and what kind of preprocessing is used to translate the image data into a sequence of bytes.

Both PNG and GIF are examples of lossless image formats that use LZ-style compression. There doesn't seem to be a very good reason to write your own, but if you replace PNG's compressor with LZSS, you'll get similar results. The DEFLATE algorithm that it uses is already a good combination of LZSS and Huffman, so maybe it already provides what you need out of the box.

  • Related