Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quadtree-image-compression

C implementation of a QuadTree-like BST for image segmentation and compression.

Quad Image BST

A C implementation of a Binary Search Tree (BST) data structure used to manage rectangular regions (quads) of an image.
This project demonstrates how image segmentation can be performed using recursive quadtree-like splitting, based on pixel similarity thresholds.

📌 Features

  • Quad Structure: Represents rectangular image regions with metadata (tx, ty, w, h, sx, wsplit, key).
  • BST Operations:
    • Insert, Search, Delete nodes
    • Inorder, Preorder, Postorder traversals
    • Recursive memory cleanup
  • Image Processing Functions:
    • get_colour: Compute average pixel colour of a quad
    • similar: Determine if a quad’s pixels are within a similarity threshold
    • split_tree: Recursively split quads into smaller regions
    • drawOutline: Draw outlines of quads on the image
    • save_Quad: Replace quad pixels with averaged colour for compression

🖼️ Example Workflow

  1. Load a grayscale image into memory
  2. Initialize the root Quad (whole image as one region)
  3. Build a BST of quads
  4. Recursively split quads using similarity threshold
  5. Save results:
    • Outlined Image → highlights quad borders
    • Compressed Image → quads filled with average colour

📂 File Structure

  • Quad.c → Main implementation of BST + image functions
  • imgUtils.c → Utility functions for image loading/saving (provided with assignment)

🔧 Compilation

To compile:

gcc Quad.c -o quad

About

C implementation of a QuadTree-like BST for image segmentation and compression.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages