Image clustering and categorization is a means for high-level description of image content. In the field of contentbased image retrieval (CBIR), the analysis of gray scale images has got very much importance because of its immense application starting from satellite images to medical images. But the analysis of an image with such number of gray shades becomes very complex, so, for simplicity we cluster the image into a lesser number of gray levels. Using K-Means clustering algorithm we can cluster an image to obtain segments. The main disadvantage of the k-means algorithm is that the number of clusters, K, must be supplied as a parameter. Again, this method does not specify the optimal cluster number. In this paper, we have provided a mathematical approach to determine the optimal cluster number of a clustered grayscale images. A simple index, based on the intra-cluster and inter-cluster distance measures has been proposed in this paper, which allows the number of clusters to be determined automatically.