Giter VIP home page Giter VIP logo

quadtree-compression's Introduction

quadtree-compression

This repository contains the result of a coding assignment completed for UBC's CPSC 221 course.

The original assignment required us to write the code for a quadtree compression algorithm as described here (alternatively check out the html file in the repo). The basic idea is to render areas of lower frequencies as constant blocks and thereby compress a given image:

Despite its origin as homework, I have decided to upload it, since it allows for a lot of insight into my current coding skills. I think, the code shows very well, that:

  • I can work on a large-scale project by myself
  • I am able to break the high-level goal up into many small steps
  • My code is legible and well-commented (very important to me)

Provided with the algorithm's logic, images of its desired outcome, and a bare-bone skeleton code, I put myself to work. As suggested by the instructions, I first had to come up with a clever method to compute the statistics necessary for the compilation of a so-called toqutree (torus-quadtree). In a second step, I had to apply the statistics in order to convert an input image recursively into a quadtree structure. Accordingly, my main contribution can be found in the following files:

  • stats.h and stats.cpp
  • toqutree.h and toqutree.cpp

(As a note to the attentive observer, my coding obviously got better over the course of writing these files. While stats.cpp contains a few long functions with many lines, toqutree.cpp is more readable thanks to the increased use of helper functions.)

In order to validate my code, I've written numerous test-cases of increasing fidelity. They can be found (partly commented-out) in testComp.cpp.

The resulting compression met all the course's requirement and got the full score. As an example, we were provided with an image that had been rendered by the instructor's algorithm (below on the left). The comparison to my result (below in the middle) shows very little deviation (below to the right, in red), that can only be explained by differences in the order of 2D-traversals of pixels.

In order to use the code, alter the relevant lines in testComp.cpp (if you choose an input image of different dimensions, don't forget to set the parameter k in toqutree t1(img, k) to min(log_2(width), log_2(height)).) Compile with make all and run with ./pa3test.

quadtree-compression's People

Contributors

nkueng 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.