A python app to demonstrate the working principle of Shannon Fano Code
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.
- 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
- Ensure Python 3.6+ is installed with Tkinter support
- Download or clone this repository
- Run the app:
- Enter the message in the left panel input box
- Click “Generate Codes” to start encoding
- View each encoding step in the “Step-by-Step Process” tab
- Explore the binary tree in the “Tree Diagram” tab
- Check the final encoded output and stats in the “Final Results” tab
- Calculate the frequency and probability of each symbol
- Sort symbols by probability in descending order
- Split symbols into two groups with near-equal total probability
- Assign '0' to upper group and '1' to lower group recursively
- Repeat until unique prefix-free binary codes are assigned to all symbols
This project is licensed under the MIT License.
Shubham Yadav
⭐ Star this repo if you find this project helpful!