An Effective Color Quantization Method Using Octree-Based Self-Organizing Maps

Color quantization is an essential technique in color image processing, which has been continuously researched. It is often used, in particular, as preprocessing for many applications. Self-Organizing Map (SOM) color quantization is one of the most effective methods. However, it is inefficient for obtaining accurate results when it performs quantization with too few colors. In this paper, we present a more effective color quantization algorithm that reduces the number of colors to a small number by using octree quantization. This generates more natural results with less difference from the original image. The proposed method is evaluated by comparing it with well-known quantization methods. The experimental results show that the proposed method is more effective than other methods when using a small number of colors to quantize the colors. Also, it takes only 71.73% of the processing time of the conventional SOM method.


Introduction
24-bit images can represent up to 16,777,216 colors. A variety of colors in an image provides the advantages of having greater abilities of expression and aesthetics. However, a variety of colors becomes a serious problem for most color image processing. Therefore, research to represent the various colors within a limited number of colors, which is called color quantization, has been conducted.
Self-Organizing Map (SOM), which is one of the most effective color quantization methods, provides excellent results [1][2][3][4][5]. However, low-frequency colors in the original image tend to be excluded during the learning process because of the characteristics of the SOM learning algorithm [6]. In addition, when SOM updates the winner node, it also updates neighbor nodes, which causes loss of the original color of the neighbor node. In particular, the loss of original color increases when SOM uses a small number of nodes to quantize the image with a small number of colors. Therefore, to complement these SOM disadvantages, we propose an effective color quantization algorithm that is effective even when it uses only a small number of colors by using an octree color quantization method.
Usually, mean absolute error (MAE), mean square error (MSE), and processing time are used to quantify the performance of the color quantization results. MAE and MSE are calculated by the following, respectively:  An octree is a tree structure with up to eight nodes as children. The octree can represent all colors in an image within an eight-level tree because the colors are represented with eight bits. At first, color distribution in the image is represented using an octree, which then prunes the nodes until nodes remain. The palette colors are chosen from the remaining nodes. This method is fast and gives good results [6,9].
As mentioned above, octree color quantization generates the palette using the distribution of colors in the image, but it does not consider the frequency of color. This means that if an image is composed of similar colors overall but has many different low-frequency colors or noise, octree's results can be very poor. Figure 1 shows the strengths and weaknesses of octree color quantization. The original image has two highfrequency colors overall and many low-frequency colors around them. Yellowish and bluish colors occupy most of the image. Because SOM quantization considers the distribution of color, the generated palette has 21 yellowish colors and 5 bluish colors. By contrast, the generated palette from octree quantization has 5 yellowish colors and 9 bluish colors. Because of this, it is not influenced by the distribution of colors, and it creates a much greater difference from the original image. This is obviously octree's weakness.
However, octree has various colors, like greenish and pinkish, which SOM does not have. This is a strength for octree for the same reason.
In this paper, we present a more effective color quantization algorithm that complements the weakness of SOM by using the strengths of octree, which are fast and offer various colors.

SOM Color Quantization
SOM color quantization shows excellent results with most images. The results are very natural and have a low MAE and MSE because the SOM learning algorithm spontaneously considers the distribution of colors.
However, when SOM color quantization has only a small number of colors (i.e., the number of colors, , becomes lower), its disadvantage is apparent. The SOM learning algorithm finds the winner node and updates its weight. At that time, neighbor nodes of the winner are also updated. This means SOM generates a more natural palette, but also it means SOM loses the original color of the neighbor nodes. High-frequency colors are learned many times, so they update the weights many times. This means that highfrequency colors influence neighbor nodes much more, because when the winner is updated, the neighbor nodes are  also updated. It becomes more serious when the number of colors, , becomes smaller. If becomes too small, then the SOM map also becomes so small that the influences on updating the winner become much greater. Therefore, the overall colors can become similar and the low-frequency colors disappear through updating the weights. Figure 2 shows quantized results with 16 colors from SOM [3,6] and octree [9]. SOM (MAE 28.93, MSE 501.62) obviously has fewer differences from the original image than octree (MAE 56.30, MSE 1609.28). However, visually, the result of octree looks better because the results from SOM lost the sky-blue color, even if octree has almost double the MAE.
SOM color quantization is excellent method, but the number of colors, , is small; then its performance is decreased. Therefore, it can be a problem when it is used to quantize an image with a small number of colors.

Octree-Based SOM Color Quantization
We present a more effective color quantization algorithm by using octree-based SOM color. It complements the disadvantages of SOM, so it not only gives visually natural results but also provides low MAE and MSE.
The beginning of the SOM learning algorithm initializes the weights with random values. It causes similar colors to be located anywhere on the palette. If they are highfrequency colors, then low-frequency colors around them are lost. Therefore, we intentionally initialize the weights with colors in the image. This can induce the results to be more similar to the original image with reduced loss of the original colors. Thus, because the initial weights are fixed, we can always get the same results, unlike traditional SOM.
The weight initialization should satisfy the following conditions to complement the problem above.
(1) The time to create the map must be short.
(2) The map should be created using the colors in the image. (3) It should be configured with a variety of colors from the image as much as possible.
Octree color quantization satisfies these conditions. It constructs the octree using the colors in the image, and it prunes them until only nodes remain. It does not need much time to create the palette. In addition, it has various colors because it does not consider the distribution of color. Therefore, the proposed method initializes the weights using the palette generated by octree quantization. Figure 3 shows the overall process of the proposed method. At first, it builds an octree on the input image and prunes the octree until nodes remain to get the number of colors for initializing the weights of SOM [9].
After initializing, SOM learning is performed. The proposed method uses a two-dimensional SOM and two different learning rates for winner and neighbor nodes. The learning rate for neighbor node neighbor is a lot smaller than the learning rate for winner node winner in order to reduce the loss of low-frequency colors.  The proposed method uses different training data in each iteration. If SOM learns sequential pixels in an image, it means SOM learns similar pixels repeatedly because adjacent pixels in an image have similar colors. The training data for th iteration, , is defined as follows for data sampling: Determining the winner node and updating the weights are performed by traditional SOM learning method as shown in the following: Algorithm 1 shows the learning algorithm of octree-based SOM color quantization.
In this paper, it assumes that the weights converge if the average variation in the weights is lower than 0.025, and it is used as an end condition. The end condition is experimental value. Figure 4 shows average MAE, MSE, and processing time of all test cases. When the end condition is set between 0.01 and 0.025, it gives best performances. It shows the end condition 0.025 is reasonable.

Experimental Results
The proposed method was tested on a set of ten true-color images commonly used to evaluate performance. The images are shown in Figure 5, and information about the test images Computational Intelligence and Neuroscience   Table 1 were calculated with (5). As this value increases, the image has various colors, and the differences among the colors are greater: We evaluated the proposed method by comparing it with well-known color quantization algorithms, such as popularity (POP) [10], octree (OCT) [9], median-cut (MC) [10],means (KM) [11], Adaptive Resonance Theory 2 (ART2) [12], and Self-Organizing Maps (SOM) [3]. Table 2 explains these  color quantization methods.  Tables 3 and 4 show a comparison of MAE and MSE, respectively. means the number of colors used for quantizing an image. The best method is indicated in bold. As expected, the experimental results show that the proposed method gives better results than the conventional SOM method when is small. It is the consequence obtained by reducing the learning rate of the neighbors. It minimizes the influence on the neighbor by the winner, so the proposed method has the original colors of the palette. It means the proposed method is more effective than other algorithms when is small.
On the other hand, the disadvantage of SOM is reduced when SOM uses a big enough size of map for learning, because the influence of the winner is decreased. Therefore, the performance gap between conventional SOM and the proposed method also decreases when is large. In some cases, the proposed method gives a larger MAE and MSE, because the low learning rate of the neighbor disturbs similar color grouping on the map. Table 5 shows the processing time of the color quantization methods. The proposed method is faster than the conventional SOM method because the weights are initialized with the palette generated by octree. On the other hand, the conventional SOM method initializes the weights with random values. It makes SOM need less time before the weights converge. Therefore, the proposed method requires only 71.73% of the processing time of the conventional SOM method.
In Figure 6, the peak signal-to-noise ratio (PSNR) is additionally measured to evaluate quantization quality. PSNR is a popular measure to evaluate the reconstruction quality of image compression codecs and thus is used to evaluate color compression quality. A higher PSNR means the color quantization method has higher quality [13]. PSNR is defined as shown in the following: PSNR = 20 × log 10 ( √ MSE ) . Figure 7 shows that the proposed method gives more similar results to the original image, visually, even if it has 6 Computational Intelligence and Neuroscience Table 2: Various color quantization methods [1].

Methods
Features of methods POP [10] (i) One of the simplest methods.
(iii) K most-frequent colors in the color histogram are used for quantization.
(ii) It makes cubes that include all of the histogram.
(iii) It repeatedly splits the cubes that have the greatest number of colors until K cubes are obtained.
OCT [9] (i) Tree structure with up to 8 nodes as children, which can represent all colors in an image within an 8-level tree.
(ii) Color distribution is represented using octree, which then prunes the nodes until K nodes remain.
(ii) All of the input data are assigned to the cluster that has the minimum distance within the data.
(iii) The centroid of the cluster is calculated as the average of the assigned data.
ART2 [12] (i) Unsupervised learning model. (ii) It creates new clusters depending on a vigilance test.
(iii) The palette color is chosen from the centroids of the most-frequent clusters.
(ii) One-dimensional self-organizing map with K neurons.
(iii) It designates the minimum distance node as the "winner" node and then updates the weights of the winner node and neighbor nodes.
(iv) It repeats the process until the sum of the weight change is less than a certain threshold.

Conclusions
In this paper, an effective color quantization method is proposed. Having many colors in the original image is a serious problem for image processing, so the number of colors must be reduced. Therefore, we propose an octreebased SOM color quantization method. It is particularly more 8 Computational Intelligence and Neuroscience effective than other algorithms when the number of colors, , is small. It uses an octree color quantization method to complement the disadvantages of SOM color quantization, which is one of the more effective methods. The octree color quantization method does not consider the distribution of colors, so its palette includes various colors. Therefore, we use the palette generated by octree to initialize the SOM weights. This causes the palette generated by SOM to have more varied colors than conventional SOM. In addition, the learning rate of the neighbors is set to low to minimize the loss of color information from updating the winner, because the influence of the winner becomes greater when is small. The low learning rate of the neighbor means the proposed method can have colors similar to the original image.
The proposed method was evaluated by comparing it with six well-known quantization methods. MAE, MSE, and processing time are measured for comparison. The experimental results show that the proposed method is more effective than other methods when it uses a smaller number of