A collection of various data compression techniques implemented in Java ☕. This repository explores both lossless and lossy compression algorithms.
This project provides Java implementations for several fundamental data compression algorithms. It serves as a practical exploration of how different techniques reduce data size, comparing lossless methods (which allow perfect reconstruction) and lossy methods (which achieve higher compression at the cost of some data loss).
These algorithms compress data without any loss of information. The original data can be perfectly reconstructed from the compressed data.
- Standard Huffman Coding 🌳: A classic algorithm that assigns variable-length codes to input characters based on their frequencies.
- Adaptive Huffman Coding 🌳🔄: An adaptive version of Huffman coding where the code tree is updated dynamically as the data is processed.
- LZ Algorithm 🤐: Implementation of an LZ-family dictionary-based compression algorithm (e.g., LZ77/LZW). (Note: Specific variant might need confirmation from code)
These algorithms achieve higher compression ratios by discarding some information deemed less critical. This is often used for images, audio, and video where perfect accuracy is not always required.
- Differential Pulse Code Modulation (DPCM) 〰️: A signal coding technique that encodes the difference between consecutive samples rather than the samples themselves.
- Trained Vector Quantization (VQ) 🔢🎯: A quantization technique that maps vectors of input data to a finite set of 'codebook' vectors, trained on representative data.
The repository is organized as follows:
|-- Lossless Compression/
|-- Adaptive_Huffman/ # Implementation of Adaptive Huffman
|-- LZ/ # Implementation of LZ algorithm
└── Standard Huffman/ # Implementation of Standard Huffman
|-- Lossy Compression/
|-- DPCM/ # Implementation of DPCM
|-- src/
|-- output/
└── DPCM Report.pdf # Report detailing the DPCM implementation
|-- Trained Vector Quantization/ # Implementation of Trained VQ
|--src/
└── Trained Vector Quantization Report.pdf # Report detailing the VQ implementation
The implementations are written in Java. To run the code:
-
Clone the repository:
git clone https://github.com/AhmedFoda54/Data-Compression-Techniques.git cd Data-Compression-Techniques -
Compile and Run: Navigate into the specific technique's directory (e.g.,
Lossless Compression/Standard Huffman/). Compile the Java source files and run the main class. You might need a Java Development Kit (JDK) installed. (Specific compilation/run commands might vary depending on the project setup within each folder - check thesrcdirectories for main classes).Example (conceptual):
cd "Lossless Compression/Standard Huffman/src" javac *.java java MainClass # Replace MainClass with the actual main class name
Detailed reports explaining the implementation and results for DPCM and Trained Vector Quantization are available within their respective folders:
Lossy Compression/DPCM/DPCM Report.pdfTrained Vector Quantization/Trained Vector Quantization Report.pdf
Feel free to explore the code and learn more about these fascinating compression techniques! ✨