Skip to content

Pumkinmarble/quad-tree-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quad-Tree Image Compression

A high-performance image processing tool that simplifies images using adaptive quad-tree partitioning with variance-based splitting.

What This Is

This is a Rust command-line tool that transforms images into a simplified representation by:

  • Dividing the image into rectangular regions of varying sizes
  • Using more detail (smaller rectangles) where the image is complex
  • Using less detail (larger rectangles) where the image is simple

The program analyzes your image and creates a quad-tree structure:

  1. Starts with the whole image as one rectangle
  2. Finds the region with the most color variation (faces, edges, text, patterns)
  3. Splits that region into 4 quadrants (northwest, northeast, southwest, southeast)
  4. Repeats for N iterations
  5. Fills each final region with its average color

Examples:

Examples

1000000 iterations

50000 iterations

25000 iterations

10000 iterations

1000 iterations

Prerequisites:

  • Rust (version 1.70 or later)

Build the Project:

cd qtree
cargo build --release

Basic Usage:

cargo run --release -- <input-image> -iter <iterations> [options]
  • <input-image> - Path to your input image (supports .jpg, .png, .gif, etc.)
  • -iter <N> - Number of subdivisions to perform
  • -o <path> - Output file path (default: input-compressed.ext in current directory)
  • -outline <hex> - Add colored borders around regions (e.g., 000000 for black, FF0000 for red)
  • -gif <interval> - Create animated GIF showing the algorithm's progress, saving every N iterations
  • -outline HEXCOLOR - Draw borders around each region, making the quad-tree structure visible.

All dependencies are automatically downloaded by Cargo.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages