I'm attempting to use a quadtree (a 4-ary tree) to hold the information in a given BMP.
I'm struggling to figure out how to build the tree given any BMP.
Basically the structure is such that every leaf represents a pixel. Each Node has 4 pointers each of which point to one of the four remaining quadrants in the image. Thus each node divides the current picture into 4 parts. By the time you are at the leaf you are at one specific pixel.
I'm not sure how to go about building a tree to map a certain image. Assuming that the image has dimensions which are powers of two, what should I do. I understand that a recursive function could probably do this most elegantly but I'm struggling to figure out how to keep track of where in the image I am going to be.
This is in C++ and currently my quadtree.h file includes a Node* root where a node is defined as being a structure with a pixel element and 4 pointers to other nodes. Each inner node (non leaf node) should hold the average value of all the 4 RGB values it leads to.
I'm attempting to make an algorithm, but I think I might need to include a struct or two in the .h file. Is there a better/more clean way to solve this problem?