## 3 Method
### K-Means Clustering and Image Processing (Unsupervised Learning)  
Segmentation of RV and FAZ in OCTA (ILM_OPL) 2D en face images using image processing and K-means (KM) clustering technique: K-means clustering (KM) is a well-known clustering approach for unsupervised learning applications. K-means can be applied to image segmentation via grouping the pixels by maximizing intersegment similarity. KM clustering is one of the widespread partitioning methods and is broadly used due to its ease, effectiveness, and comfort of implementation. Based on a distance measure, it partitions data samples into different clusters. Then it finds a partition such that the squared error between the centroid and the points in the cluster is minimized. Let \(O=\{O_{1},O_{2},\ldots,O_{n}\}\), a set of n data specimens to be clustered into a set of K cluster \(C=\{C_{i},\,i=1,\ldots,k\}\). The objective of KM is to reduce the sum of the squared error over all K clusters, defined as follows in Equation (1):  
\[J(C)=\sum_{i=1}^{k}\sum_{O_{i}\in C_{i}}(O_{l}-Z_{i})^{2} \tag{1}\]  
where \(i\) is the index of the cluster, ranging from 1 to \(k\). \(l\) is the index of the data sample within a cluster, ranging from 1 to the number of data samples in the i-th cluster. \(C_{i}\) is the \(i\)-th cluster, \(Z_{i}\) the centroid for the \(i\)-th cluster, \(O_{l}\) is data samples from the \(i\)-th cluster, and \(k\) represents the total number of clusters [32]. Now we can provide the steps of implementation as follows:  
1. Convert the given image into a grayscale image and smooth the image with a 3 \(\times\) 3 kernel Gaussian blur [33] filter. Gaussian blur reduces image noise by blurring it with a Gaussian function. It is a non-uniform low-pass filter that lowers image noise and noiseless details. Reshape the image array (3D) as a vector (1D) to apply to the cluster. The effectiveness of a Gaussian blur filter is to enhance vascular contrast and connectivity, which enhances the quality of the OCTA angiograms [34]. 2. We convert reshaping values to a floating point because each feature should be in a single column for K-means. Specify K-means convergence criteria, the point at which the algorithm stops iterating. Once the specified requirements are met, the algorithm terminates. The convergence criteria used in the segmentation function specifies that the K-means clustering algorithm should stop when either the desired accuracy or the maximum number of iterations is reached, whichever comes first. The maximum number of iterations is set to 10, and the desired accuracy is set to 1.0. This means that the algorithm will stop after 10 iterations or earlier if the desired accuracy is achieved. The convergence criterion is an important parameter in the K-means algorithm as it determines when the algorithm has converged to a stable solution and can be used to optimize the clustering process. 3. Apply the K-means algorithm with K = 4 to divide the OCTA en face image into four clusters. After performing K-means clustering, we extract the compactness, labels, and centers to identify the regions. Finally, it returns a list of labels corresponding to each cluster and their centers (in this case, where they are located on the original image). 4. We access the labels and convert the label array to a clustered image; every pixel represents its clustering label. Therefore, we can establish a list of the images in our clustered image, calculate the minimum and maximum values for each image,then create an empty 3-dimensional array to record each pixel's color. Next, it loops through each image's pixels to assign color values. 5. Specifically, the maximum pixel values are converted to 255, and the minimum pixel values are converted to 100. Other two-pixel values represent 0. Then, a smooth function is applied to remove noisy dots in the image.