This project is a Lossless Image Compression Tool capable of shrinking file sizes by 40-50% without losing any visual data. It implements the Huffman Coding Algorithm from scratch using C++.
The tool is specifically optimized for PGM (Portable Gray Map) images, commonly used in medical imaging (DICOM), and features a user-friendly Qt GUI for easy encoding/decoding operations.
- Core Algorithm:
- Implements Greedy Strategy using Min-Heap (Priority Queue) to build the Optimal Huffman Tree.
- Generates variable-length binary codes based on pixel frequency (frequent pixels = shorter codes).
- Serialization: Saves the compressed data along with the Huffman Tree structure (Header) to allow perfect reconstruction.
- Qt GUI:
- Visualize compression ratio.
- Toggle between Compress/Decompress modes easily.
- Performance: Optimized C++ file I/O for handling large raw image binaries.
The system relies on advanced Data Structures:
- Frequency Map: Hash map to count pixel occurrences.
- Priority Queue: To select the two smallest probability nodes iteratively.
- Binary Tree: To generate unique prefix codes (0/1 paths).
- Bit Manipulation: Packing bits into bytes for physical storage.
- C++ Compiler (GCC/Clang)
- Qt Creator (or Qt 5.x Libraries)
- Clone the Repository:
git clone [https://github.com/mariamashraf731/Huffman-Image-Compressor.git](https://github.com/mariamashraf731/Huffman-Image-Compressor.git)
- Open in Qt Creator:
- Open
src/gui/GUI.pro. - Configure Project & Build.
- Open
- Run:
- Load a
.pgmimage to compress. - Or load a
.encfile to decompress.
- Load a
For the mathematical proof and algorithmic details, check the Final Report.