Giter VIP home page Giter VIP logo

adapt-huff's Introduction

adaptive-huff

About

The code is for experimenting adaptive huffman compression with some raw data images.
(ie. Baboon and lena in raw,halftone and binary color)

How to run

Environment

  • Visual Studio Code
  • Poetry 1.0.10 or later

Step

  1. Clone this repository to local
  2. Open the root directory.
cd adaptive_huffman_coding
  1. Install the dependencies with Poetry.
poetry install --no-root
  1. Run main.py
python3 main.py

Data Structure

Use a DAG, which has 2 children and parent pointer for every node, to implement Huffman tree. The code of a node is generated when we search for it (Tree.search() in class Tree of tree.py), and thus the code for every node will not be updated when exchanging or appending. Furthermore, we use an array (self.all_nodes in class AdaptiveHuffman of ada_huffman.py) to keep track of each node within the tree. By doing this, we could search a node within the tree iteratively instead of recursively traversal.

Experiment statistic

Baboon

Baboon

Image(256*256) Entropy(bit) Before(byte) After(byte) -without header Header(byte) Compression Rate
baboon_b 0.96909 65536 11446 4 82.53%
baboon_halftone 0.96136 65536 11347 4 82.68%
baboon_raw 7.24065 65536 59828 146 8.71%

Lena

Lena

Image(256*256) Entropy(bit) Before(byte) After(byte) -without header Header(byte) Compression Rate
lena_b 0.96968 65536 11454 4 82.52%
baboon_halftone 0.83681 65536 10380 4 84.16%
baboon_raw 7.59536 65536 62832 214 4.13%

origin

forked from https://github.com/seanwu1105/adaptive-huffman-coding

adapt-huff's People

Contributors

eagletw avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.