## 2 Methods
### Color Extraction
#### 2.3.3 Determination of the Cluster Number  
Before the clustering analysis, the elbow method and silhouette coefficient method were used to determine the optimal cluster number (the K-value). The elbow method is proposed to explain and verify the consistency of the clustering analysis, aiming to find the appropriate number of clusters in the dataset. The elbow method is a heuristic used to determine the optimal number of clusters in partitioning clustering algorithms such as k-means, k-modes, and k-prototypes clustering algorithms. With the increase in the number of clusters, the total cluster variance for a given dataset decreases rapidly. After a point, the total cluster variance becomes almost constant or the rate of decrease in total cluster variance becomes very low. The calculative formula is shown in Equation (2):  
\[SSE=\sum_{i=1}^{K}\sum_{p\in C_{i}}|p-m_{i}|^{2} \tag{2}\]  
In Equation (2), \(SSE\) is the sum of the squared errors, \(p\) is the element of cluster \(C_{i}\), \(K\) is the number of clusters, and \(m_{i}\) is the mean value of all elements in \(C_{i}\). \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Original Image**} & \multirow{2}{*}{**Methods**} & \multirow{2}{*}{\begin{tabular}{c} **The Set of** \\ **K-Values** \\ \end{tabular} } & \multicolumn{4}{c}{**Extracted Results**} \\ \cline{3-6}  & & & **Color Cards** & **Color Number** & **Running Time** \\ \hline \multirow{4}{*}{\begin{tabular}{c} **Octree** \\ quantization \\ \end{tabular} } & Octree & & & & 7 & 9 s \\  & quantization & & & & & \\  & K-means clustering & & & & 3 & 37 s \\ \hline \multirow{4}{*}{\
\begin{tabular}{c} **Octree** \\ quantization \\ \end{tabular} } & Octree & & & & 8 & 30 s \\  & quantization & & & & 5 & 71 s \\ \cline{1-1}  & K-means clustering & & & & 5 & 12 s \\ \hline \multirow{4}{*}{
\begin{tabular}{c} **Octree** \\ quantization \\ \end{tabular} } & Octree & & & & 5 & 12 s \\ \cline{1-1}  & quantization & & & & 6 & 70 s \\ \cline{1-1}  & K-means clustering & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of the results from the octree and K-means algorithms. The degree of sample division and clustering center aggregation are proportional to \(K\), and SSE is inversely proportional to \(K\). When the K-value is less than the actual number of clusters, as \(K\) increases, the aggregation degree of each cluster center will be greatly increased, and \(SSE\) will be greatly reduced. When \(K\) is greater than the actual number of clusters, although \(SSE\) is also showing a downward trend as \(K\) increases, it eventually tends to be flat. It could be seen that the relationship between \(SSE\) and \(K\) was elbow-shaped, and the K-value corresponding to the elbow was the best. Silhouette coefficient is also a way to evaluate the cluster effect with two factors of cohesion and separation. The silhouette coefficient is a metric used to evaluate the quality of clustering in computer science. It measures the coherence of clusters, with a higher coefficient indicating more coherent clusters. The silhouette coefficient \(S(i)\) evaluates if a single sample is gathered reasonably in a category. The specific formula is shown in Equation (3):  
\[S(i)=\frac{b(i)-a(i)}{\max\{a(i),b(i)\}} \tag{3}\]  
In Equation (3), \(a(i)\) is the average distance between data sample \(i\) and all other samples in its cluster, and \(b(i)\) is the minimum average distance between sample \(i\) and all the samples in any other cluster without the sample \(i\). For each type \(i\), \(S(i)\) varies between \(-1\) and \(1\). When \(S(i)\) is close to \(1\), the value of \(a(i)\) is much smaller than \(b(i)\), which means that sample \(i\) is assigned to an appropriate cluster with a good cluster effect. However, when \(S(i)\) is close to \(0\), the values of \(a(i)\) and \(b(i)\) are approximately equal, and it is not clear to which cluster type sample \(i\) belongs.