# Color Classification of Wooden Boards Based on Machine Vision and the Clustering Algorithm +
## 6 Experiments
### Performance with Different Numbers of Clusters  
We firstly study the classification performance with different numbers of clusters. The numbers of clusters \(k\) are set as 20, 40, and 60, respectively. The number of bins is fixed at \(N_{b}\) = 16. Three metrics are used for evaluating the clustering results. The mean squared distance is the average of the squared distances of samples to their closest cluster center. Silhouette scores [17] range from \(-1\) to 1: a high silhouette score indicates that the object is well matched to its own cluster and distinct from neighboring clusters. The Calinski-Harabasz score of a clustering is in [0, +\(\infty\)] and should be maximized [28]. The results are given in Table 1. When we choose \(k\) to be 20, the mean squared distance is 0.00295, the global mean silhouette score is 0.155, and Calinski-Harabasz score is 1767. When there are 40 clusters, the three values are 0.00225, 0.146, and 1248, respectively. With \(k\) = 60, we obtain 0.00192, 0.143, and 1008. As the number of clusters increases from 20 to 40 and then to 60, the global mean silhouette score and Calinski-Harabasz score decrease, which indicates that the quality of the clustering result becomes poorer. On the other hand, the value of the mean squared distance becomes smaller, which indicates that the similarity between the objects in their own cluster becomes greater. According to the opposite results given above, it is hard to evaluate the performance of the color classification of wooden boards simply based on traditional clustering metrics. To solve this problem, we propose a new metric to evaluate the accuracy of color classification manually. We design software to display the test image and the representative image simultaneously. The representative image of each cluster is determined by the image in the cluster that is closest to its centroid. Then, the volunteers are asked to filter the images that are clearly different from the representative image. The definition of the proposed classification accuracy is the percentage of images that are not filtered by the volunteers. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Metric** & **20** & **40** & **60** \\ \hline Mean squared distance & 0.00295 & 0.00225 & 0.00192 \\ Global mean silhouette score & 0.155 & 0.146 & 0.143 \\ Calinski–Harabasz score & 1767 & 1248 & 1008 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Clustering metrics with different numbers of clusters. Figure 9: The numbers of pixels with each value in the R, G, and B channels. In this experiment, one-thousand images are classified by the clustering result with different numbers of clusters, respectively. Five volunteers, which consist of three experts (A, B, and C) and two students (D and E), are asked to judge the classification results. Table 2 shows the classification accuracy determined by the volunteers. The average classification accuracies of the proposed mechanism with 20, 40, and 60 clusters are 91.8%, 94.3%, and 96.8%, respectively, which indicates that the classification accuracy increases as the number of clusters grows. It is important to note that the classification accuracy with the same number of clusters is obviously different among different volunteers. This verifies the difficulty in classifying wood color manually. On the other hand, it is obvious that the classification accuracy determined by the students is higher than that by the experts. This indicates that the untrained volunteers have difficulty discerning the color differences among some wooden boards. Furthermore, we compare the images filtered by the three experts. For each pair of experts, the numbers of images filtered by both experts are counted. The results are reported in Table 3. With \(k=20\), the number is 41, 34, and 25, respectively. Compared with the result given in Table 2, the same selected images are fewer than the total number of selected images for each judgment result, which indicates that the experts have different perspectives on comparing the color similarity of wooden boards.