Skip to content

A Lossless Image Compression tool implemented in C++ and Qt using Huffman Coding algorithm. Features a custom binary tree implementation for optimizing PGM medical images storage.

Notifications You must be signed in to change notification settings

mariamashraf731/Huffman-Image-Compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ Huffman Image Compressor (C++ & Qt)

Language GUI Algorithm

πŸ“Œ Project Overview

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.

βš™οΈ Key Features

  • 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.

πŸ› οΈ Technical Implementation

The system relies on advanced Data Structures:

  1. Frequency Map: Hash map to count pixel occurrences.
  2. Priority Queue: To select the two smallest probability nodes iteratively.
  3. Binary Tree: To generate unique prefix codes (0/1 paths).
  4. Bit Manipulation: Packing bits into bytes for physical storage.

πŸš€ How to Build & Run

Prerequisites

  • C++ Compiler (GCC/Clang)
  • Qt Creator (or Qt 5.x Libraries)

Steps

  1. Clone the Repository:
    git clone [https://github.com/mariamashraf731/Huffman-Image-Compressor.git](https://github.com/mariamashraf731/Huffman-Image-Compressor.git)
  2. Open in Qt Creator:
    • Open src/gui/GUI.pro.
    • Configure Project & Build.
  3. Run:
    • Load a .pgm image to compress.
    • Or load a .enc file to decompress.

πŸ“„ Documentation

For the mathematical proof and algorithmic details, check the Final Report.

About

A Lossless Image Compression tool implemented in C++ and Qt using Huffman Coding algorithm. Features a custom binary tree implementation for optimizing PGM medical images storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6