Region growing, clustering, and thresholding are some of the segmentation techniques that are employed on images. K-means clustering is one of the proven efficient techniques in color segmentation. Finding the value of K that produces the most effective segmentation results is a crucial research issue. In this paper, we suggested an algorithm to determine the optimal K using the Gray Level Cooccurrence Matrix (GLCM). We retrieve the correlated features from the GLCM and calculate their aggregate probability of occurring given the pixel pairings. The number K is represented as spikes in this correlation. The results demonstrated our algorithm’s excellent efficiency, with 98% percent accuracy.