Skip to content

GalanRaduM24/QuadTree-Pictures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuadTree Image Processor

Overview

This project implements a QuadTree data structure for image processing. It reads two QuadTree representations from an input file, constructs the QuadTrees, equalizes their heights, merges them, and performs various operations to visualize and analyze the resulting images.

Features

  • Construct QuadTrees from string representations.
  • Pre-order traversal of QuadTrees.
  • Equalize the height of two QuadTrees.
  • Merge two QuadTrees.
  • Convert QuadTrees to matrix representations.
  • Calculate the number of black pixels in the resulting image.
  • Display QuadTree nodes at specific levels for debugging.

Code Overview

main.cpp

The main file contains the core logic for:

  • Reading QuadTree representations from an input file.
  • Constructing QuadTrees.
  • Equalizing the heights of the QuadTrees.
  • Merging the QuadTrees.
  • Displaying QuadTrees in pre-order traversal and matrix representation.
  • Calculating the number of black pixels.

QuadTree.h

This header file defines the QuadTree class and its associated methods:

  • inserare_rec: Constructs a QuadTree from a string representation.
  • createMatrix: Creates a matrix representation of the image from the QuadTree.
  • calculateBlackPixelCount: Calculates the number of black pixels in the matrix.
  • equalizeTree: Equalizes the height of the QuadTree.
  • mergeTrees: Merges two QuadTrees.
  • preOrderTraversal: Performs a pre-order traversal of the QuadTree.
  • maximumHeight: Calculates the maximum height of the QuadTree.
  • Display: Displays the QuadTree nodes at a specific level.
  • createMatrixRecursive: Fills the matrix from the QuadTree.

Example

For inputs:

ppwwwbpbbwwbw
pwbwpwwbw

We obtain:

QuadTree 1: ppwwwbpbbwwbw
QuadTree 2: pwbwpwwbw
Equalized Tree1:
ppwwwbpbbwwpbbbbpwwww
Equalized Tree2:
ppwwwwpbbbbpwwwwpwwbw
Merged QuadTree: ppwwwbbbpwwbw

Image Representation:

QuadTree1:

alt text

QuadTree2:

alt text

MergedTree:

alt text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages