To perform k-means clusterization, we should use the cv2.kmeans function. It takes the following arguments, respectively, input data, the number of clusters, an input/output array with labels (can be set to None), stop process criteria, the number of attempts, and flags to control the process of clusterization.
Let's discuss each argument. The input data must be a vector of points with float values, in our case, we have three-dimensional points. The number of clusters determines how many of them we will get in the result, the greater the value, the greater the number of clusters, but the higher the influence of noise. The input/output array with labels can be used both to determine the initial positions of the clusters and ...