# An Efficient Palette Generation Method for Color Image Quantization
## 4 Experimental Results and Discussion  
The proposed algorithm is implemented in C language. All of the experiments were performed on a PC running under the operating system of Windows 7, with an I7 processor (3.6 GHz) and 32 GBytes of RAM. The set of test images includes Lena, Baboon, Lake, Peppers and Airplane, which have the same size of 512 \(\times\) 512 pixels. They were downloaded from [26] and were used for conducting the experiments. The parameters \(Thr=10\) and \(Max\_cycle=20\) were used in the experiments. The experimental results are shown in Table 1. The results presented are the solutions with the mean square error, the required iteration number, and computation time. The mean square error (MSE) is defined as follows:  
\[MSE=\frac{1}{512\times 512}\sum_{i=0}^{511}\sum_{j=0}^{511}SED\big{(}f(i,j),\ f^{ \prime}(i,j)\big{)}, \tag{8}\]  
where \(f\) is the original color image, and \(f^{\prime}\) is the quantized image. For the same image and same color palette size, we can observe the following:  
1. The mean square errors obtained when the sampling rate = 1, 0.5, 0.25 and 0.125 are near, and the mean square error obtained when the sampling rate = 0.03125 is higher than that obtained when the sampling rate = 1, 0.5, 0.25, 0.125 and 0.0625 in most cases. 2. When the sampling rate decreases, the computation time decreases in most cases. Table 2 shows the computation time (milliseconds) of the proposed method with a sampling rate of 0.125. The total computation time is the summation of T1 and T2. T1 is the computation time for initial palette generation and T2 is the computation time for clustering by the fast K-means algorithm. It is observed that the value of T1 is between 10 and 30 milliseconds, the value of T2 is between 20 and 200 milliseconds, and the total computation is between 30 and 230 milliseconds. For the Lena image, the required iteration numbers are 18 and 13 for \(K=128\) and 256, respectively. Therefore, the results show that the total computation time when \(K=256\) is less than the total computation time when \(K=128\). Figures 5-9 illustrate the quantized images of Lena, Baboon, Lake, Peppers, and Airplane, respectively. The color numbers of the palette range from 32 to 256. These quantized images are produced by the proposed method with a sampling rate of 0.125. It shows that as the color number of the palette increases, the quality of the quantized image produced by the proposed method always improves. It is noted that the visual quality of the 256 colors quantized image is approximately the same as that of the original image. \begin{table}
\begin{tabular}{c c c c c c c c c c c c c c} \hline \hline  & \multicolumn{4}{c}{\(K\) = 32} & \multicolumn{4}{c}{\(K\) = 64} & \multicolumn{4}{c}{\(K\) = 128} & \multicolumn{4}{c}{\(K\) = 256} \\ \hline
**Image** & **Sr** & **MSE** & **Iter T** & **MSE** & **Iter T** & **MSE** & **Iter T** & **MSE** & **Iter T** & **MSE** & **Iter T** \\ \hline \multirow{6}{*}{Lena} & 1 & 123.10 & 13 & 410 & 74.00 & 15 & 590 & 4  
Figure 5: **(a)** The Lena image, **(b)** 32 colors with MSE = 123.84, **(c)** 64 colors with MSE = 74.31, **(d)** 128 colors with MSE = 47.86, **(e)** 256 colors with MSE = 32.24. _Appl. Sci._**2021**, _11_, 1043  
Figure 6: **(a)** The Baboon image, **(b)** 32 colors with MSE = 383.92, **(c)** 64 colors with MSE = 241.11, **(d)** 128 colors with MSE = 154.91, **(e)** 256 colors with MSE = 100.22. Figure 7: **(a)** The Pepper image, (**b**) 32 colors with MSE = 230.00, (**c**) 64 colors with MSE = 137.14, (**d**) 128 colors with MSE = 85.87, (**e**) 256 colors with MSE = 55.70. _Appl. Sci._**2021**, _11_, 1043  
Figure 8: (**a**) The Lake image, (**b**) 32 colors with MSE = 211.57, (**c**) 64 colors with MSE = 135.67, (**d**) 128 colors with MSE = 87.99, (**e**) 256 colors with MSE = 58.44. In addition, two color images, Splash and Tree, were used for testing. The Splash image consists of 512 \(\times\) 512 pixels, and the Tree image consists of 256 \(\times\) 256 pixels.