# How to Cluster Image Colors Using K Means Clustering in CIE a*b Domain?

I am working on building detection from aerial images using Image Processing in MATLAB.

I am doing an image segmentation based on the local homogeneity of image. I want to apply K Means Clustering in CIE LAB Color Space with some clusters on the anistropic diffused image for color quantization and generate the image for further processing.
My RGB image is of 877 X 454 dimension.

How do I do that?

Thanks

You should use makecform to create a color transfer structure.
You should use srgb2lab to create a structure which will convert you to LAB.
To apply the color transformation use applycform.
Then, as a result you'll have an image in the LAB domain.

Then use kmeans to cluster the image colors on the AB channels.

Good Luck...