This has the effect of minimizing any quantization error when merging two nodes together. When a node to be pruned has offspring, the pruning procedure invokes itself recursively in order to prune the tree from the leaves upward. This retains the pruned node's color characteristics for later averaging. For each node, n2 pixels exist for which that node represents the smallest volume in RGB space containing those pixel's colors. This includes n1 - n2 pixels whose colors should be defined by nodes at a lower level in the tree.
Assignment generates the output image from the pruned tree.
A pixel array, which represents each pixel as an index into the color map array. First, the assignment phase makes one pass over the pruned color description tree to establish the image's color map. This produces the mean color of all pixels that classify no lower than this node. Each of these colors becomes an entry in the color map. Finally, the assignment phase reclassifies each pixel in the pruned tree to identify the deepest node containing the pixel's color.