Abstract
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. SelfOrganizing 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 wellknown 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.
1. Introduction
24bit 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.
SelfOrganizing Map (SOM), which is one of the most effective color quantization methods, provides excellent results [1–5]. However, lowfrequency 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:where denotes the original image, denotes the quantized image, and and denote image height and width, respectively.
2. Octree Color Quantization
An octree is one of the imagedependent methods classified as a hierarchical clustering method. It is faster than partitional clustering methods, but its performance is relatively poor [7, 8].
An octree is a tree structure with up to eight nodes as children. The octree can represent all colors in an image within an eightlevel 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 lowfrequency 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 lowfrequency 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.
3. 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. Highfrequency 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 lowfrequency 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 skyblue 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.
4. OctreeBased SOM Color Quantization
We present a more effective color quantization algorithm by using octreebased 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 lowfrequency 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 twodimensional SOM and two different learning rates for winner and neighbor nodes. The learning rate for neighbor node is a lot smaller than the learning rate for winner node in order to reduce the loss of lowfrequency 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 octreebased 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.
5. Experimental Results
The proposed method was tested on a set of ten truecolor images commonly used to evaluate performance. The images are shown in Figure 5, and information about the test images is in Table 1. Test images (i) and (j) are collected from Berkeley color image database (http://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds). All of the color quantization methods were tested on an Intel i54460 3.2 GHz, 8.0 GB RAM machine and were implemented in C++.
(a) Lenna
(b) Parrots
(c) Mona Lisa
(d) House
(e) Mandrill
(f) Venus
(g) Bedroom
(h) Scream
(i) Old man
(j) Dragonfly
The color differences shown in 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 wellknown color quantization algorithms, such as popularity (POP) [10], octree (OCT) [9], mediancut (MC) [10], means (KM) [11], Adaptive Resonance Theory 2 (ART2) [12], and SelfOrganizing 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 signaltonoise 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:
Figure 7 shows that the proposed method gives more similar results to the original image, visually, even if it has similar MAE and MSE. Overall colors in the palette generated by SOM become similar if is small. However, the proposed method has colors more similar to the original image because of the low learning rate of neighbors and initialization by octree colors. The proposed method gives more similar sky color on scream image and gives more similar background color on Mona Lisa image.
6. 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 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 wellknown 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 colors to quantize the colors in the image (). It gives lower MAE and MSE. Thus, the proposed method requires only 71.73% of the processing time of the conventional SOM method. On the other hand, when it uses a large number of colors, the performance of the proposed method gives similar MAE and MSE with conventional SOM, but it is still faster.
It is expected that the proposed method will be available to many applications that have a problem with varied colors in images.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Acknowledgment
This work was supported by BK21PLUS, Creative Human Resource Development Program for IT Convergence.