In a matrix-based (MX) octree, the subdivision point is implicitly the center of the space the node represents.The node index to branch out from at the top level is determined by a formula that uses the most significant bits of the red, green, and blue color components, e.g. 4r + 2g + b.Once sampling is complete, exploring all routes in the tree down to the leaf nodes, taking note of the bits along the way, will yield approximately the required number of colors.The example recursive algorithm outline below (MATLAB syntax) decomposes an array of 3-dimensional points into octree style bins.Examples of such exit conditions (shown in code below) are: Taking the full list of colors of a 24-bit RGB image as point input to the Octree point decomposition implementation outlined above, the following example show the results of octree color quantization.