I'm doing some image analysis of samples of pseudomona. I'm using k-means clustering to obtain different levels of presence of the bacteria along the sample, as it changes tonality as it increases its presence.

Now I want to obtain a GLCM matrix to look into contrast, entropy and other parameters, as I think it will give new information about biofilm growth and morphology. I've been using 8 clusters as a default in all my images (subjective choice), I do not want to use and 8-bit square matrix (256x256 square) because it sounds computationally expensive and wrong, an idea that came to me is to replace the values of every cluster with its correspondent level: 1-8, and then obtain a 3-bit square matrix to analyze everything in the image. My question goes into how do I change the values of every cluster to a new value?, this new value should go from 1-8, from the palest color to the most intense. Also, how do I obtain a percentage representation of the clusters and the color it represents? I'm looking into it, but a little help would be appreciated.