Skip to content

code0era/Shannon-Fano-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Shannon-Fano-visualizer

A python app to demonstrate the working principle of Shannon Fano Code

Shannon-Fano Coding Visualizer

Overview

This Python Tkinter application visually demonstrates the Shannon-Fano coding algorithm, a fundamental lossless data compression method. It allows users to input messages, and showcases a step-by-step encoding process including frequency calculation, probability sorting, recursive division, and code assignment. The project features a professional two-panel GUI with interactive binary tree visualization and comprehensive compression statistics.

Features

  • User-friendly, modern GUI with dark/light themed panels
  • Step-by-step visualization of Shannon-Fano encoding
  • Interactive binary tree construction and display
  • Detailed compression statistics, including entropy and efficiency
  • Error-free real-time encoding for messages of varying length

Installation

  1. Ensure Python 3.6+ is installed with Tkinter support
  2. Download or clone this repository
  3. Run the app:

How to Use

  1. Enter the message in the left panel input box
  2. Click “Generate Codes” to start encoding
  3. View each encoding step in the “Step-by-Step Process” tab
  4. Explore the binary tree in the “Tree Diagram” tab
  5. Check the final encoded output and stats in the “Final Results” tab

How Shannon-Fano Works

  1. Calculate the frequency and probability of each symbol
  2. Sort symbols by probability in descending order
  3. Split symbols into two groups with near-equal total probability
  4. Assign '0' to upper group and '1' to lower group recursively
  5. Repeat until unique prefix-free binary codes are assigned to all symbols

Screenshots

Screenshot 2025-10-29 195740 Screenshot 2025-10-29 195757 Screenshot 2025-10-29 195812 Screenshot 2025-10-29 195839 Screenshot 2025-10-29 195907

License

This project is licensed under the MIT License.

Author

Shubham Yadav


⭐ Star this repo if you find this project helpful!

About

A python app to demonstrate the working principle of Shannon Fano Code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages