void assignment() {
            colormap = new int[colors];

            colors = 0;
            root.colormap();

            int pixels[][] = this.pixels;

            int width = pixels.length;
            int height = pixels[0].length;

            Search search = new Search();

            // convert to indexed color
            for (int x = width; x-- > 0;) {
                for (int y = height; y-- > 0;) {
                    int pixel = pixels[x][y];
                    int red = (pixel >> 16) & 0xFF;
                    int green = (pixel >> 8) & 0xFF;
                    int blue = (pixel >> 0) & 0xFF;

                    // walk the tree to find the cube containing that color
                    Node node = root;
                    for (;;) {
                        int id = (((red > node.mid_red ? 1 : 0) << 0) | ((green
                                > node.mid_green ? 1 : 0) << 1) | ((blue
                                > node.mid_blue ? 1 : 0) << 2));
                        if (node.child[id] == null) {
                            break;
                        }
                        node = node.child[id];
                    }

                    if (QUICK) {
                        // if QUICK is set, just use that
                        // node. Strictly speaking, this isn't
                        // necessarily best match.
                        pixels[x][y] = node.color_number;
                    } else {
                        // Find the closest color.
                        search.distance = Integer.MAX_VALUE;
                        node.parent.closestColor(red, green, blue, search);
                        pixels[x][y] = search.color_number;
                    }
                }
            }
        }