-
This is the java implementation of the
LZW Compression and Decompression
algorithm. -
I wrote this code to help me implement the algorithm in
VHDL
but I decided to post it as to help people who might have an intrest in algorithm understand it better or for people who need it to simply use it. -
The binary string I've added and used is an English tongue twister to demonstrate the effectiveness.
Current Encoded-to-Decoded ratio is 0.579!
-
I've added extencive comments as per the request of the people who messaged me. I wrote it in such a way as to make it easy to understand for even the absolute beginners (with simple OOP knowledge)
I might add an implementation of the LZ77 algorithm sometime in the future. If you want me to prioritize it, message me.
JAVA SE 14
- Download the
Java SDK
from oracle or from your linux repository. - Import the
Encoder
and theDecoder
files into your project or simply clone this project.
-
Prepare the sequence of bytes to be encoded. How you transform them to bits is up to you.
This implementation of LZW ONLY works when given Strings of bit/byte sentences
-
Construct both the
Encoder
and theDecoder
with the sameBit space value
Encoder encoder = new Encoder(9);
Decoder decoder = new Decoder(9);
- Call the Classes' respective methods to utilize its effectiveness!
encoder.encodeBinary(binaryString);
decoder.decodeBinary(binaryString);
To help with this expantion I had the algo print out "out of memory" when it runs out of memory so that you can increase the allocated memory
(Bit space value)
as you need. A bigger than neededBit space value
will cause inefficiency on the software side of things and extra costs on the Hardware side.
- Comment EVERYTHING!
- Make the LZW algo scalable
- Implement the LZ77 algo (Maybe?)