This repository contains a Python implementation of a quadtree-based image compression algorithm. The implementation includes classes and functions to build a quadtree, compress colors, and reconstruct images from quadtree data.
Contains the implementation of the quadtree data structure and related functions.
- Data Structures:
quadtree.py
- Classes:
Node
,Quadtree
- Functions:
build_quadtree(qt)
quadtree_to_image(qt, draw_box=False)
compress_quadtree(qt, threshold)
count_nodes(node)
max_num_nodes(N)
Contains examples and tests for the quadtree image compression algorithm. The notebook includes image resizing and compression demonstrations.
Contains images used for testing and demonstration purposes in the testing.ipynb
notebook.
To use the quadtree image compression algorithm:
- Ensure you have the necessary libraries installed, including
numpy
. - Import the necessary classes and functions from
main.py
. - Create a
Quadtree
object with an image array. - Build the quadtree using
build_quadtree(qt)
. - Compress colors using
compress_quadtree(qt, threshold)
. - Reconstruct the image using
quadtree_to_image(qt)
.
Refer to the testing.ipynb
notebook for examples and demonstrations.
The testing.ipynb
notebook provides examples and tests for the quadtree image compression algorithm. It includes step-by-step demonstrations of building quadtrees, compressing colors, and reconstructing images.