# CIELAB Color Clustering

I am trying to understand if there is an inherent advantage to using CIELAB for color-based segmentation.

I segmented the cytoplasm from the image above, where the left image below is from RGB color clustering, and the right one is from CIELAB clustering, where a and b matrices were used.

You can see that there are very slight differences between the methods, where in this case, CIELAB clustering seems to work a bit better, but there are other examples where it doesn't.

So my question is, can you give me the reasons for using CIELAB?

If it's too much of a bother to explain, a good article reference would be nice, it would be better if it includes some mathematical explanation as well.

• I hope you're using the right metric. – Emre Jun 23 '14 at 22:50
• It appears I used the 76 metric, I'll have to modify the code to use the 2000 metric. Thanks! – user3148616 Jun 24 '14 at 3:01
• I modified the K-means code to accommodate the CIELAB metrics, though other then significantly increasing running time, it didn't make a big difference. Buy I suppose that mathematically, this is the correct way to go. – user3148616 Jun 24 '14 at 7:18

Generally speaking, a change of color space is essentially a nonlinear transform that stretches and distorts the coordinates. The transform is also continuous, except maybe on a singularity line or half-plane. It does not preserve the distances, but preserves the neighborhoods.

In the case of RGB > Lab, you can see it as a linear transform (change of basis, from RGB to XYZ) followed by a nonlinear transform of every coordinate independently (rescaling of XYZ to Lab). The topology is essentially preserved.

On the other hand, image segmentation algorithms do their best to delimit clusters of similar colors and separate the clusters from other clusters. So if you just deform the clusters, a good segmentation algorithm will adjust the boundaries and somehow undo the transform. If you repeat the experiment with XYZ or YUV coordinates, you should see no big difference either.

A stronger qualitative difference can be observed if the topology of the space is modified, for example by moving to the HSV space (Cartesian to cylindrical coordinates), of by performing some projection to lower the dimensionality such as XYZ > xyz. But beware of the physical interpretation of what you are doing.

The problem is that the B channel in your image is uninformative, and the A channel does not get you where you want to go with clustering by itself. In this case, your subject is circular, so I would use morphological analysis instead of color segmentation. It's easy to detect ellipses and circles with the right software; e.g., Mathematica:

img = Import["http://i.stack.imgur.com/glbuL.png"]
cells = SelectComponents[ChanVeseBinarize@img, "FilledCircularity", # > 0.7 &]
circles = ComponentMeasurements[ImageMultiply[img, cells], {"Centroid", "SemiAxes"}][[All, 2]] //
List[{#1[[1, 1]], #[[1, 2]] // Reverse}] &
Show[img, Graphics[{Red, Thick, Circle @@ # & /@ circles}]]


• Thanks, I did use a similar method on Matlab in order to extract the major/minor axes ratio as a feature for classification. I think I managed to obtain an ok segmentation (combined with watershed and spatial clustering), as can be seen here: link. I was just trying to better understand the benefits of changing to LAB* color space. – user3148616 Jun 24 '14 at 12:18
• Good! Before giving up on clustering, I would treat color space conversion as a starting point. Next I would perform an affine transformation as a prelude to classification -- like linear discriminant analysis. Photographers do this in Photoshop all the time; here are some tutorials. You can translate to MATLAB – Emre Jun 24 '14 at 18:18
• Thanks! Is it meant to improve the cell segmentation? If so, then great! not all of my images were segmented properly. About classification, I guess it's not relevant to the topic of the question, but I'm supposed to classify between ill and healthy white blood cells. I'm currently using Random Forest for that task, because gives me a good idea about which features helped or ruined my classification. – user3148616 Jun 24 '14 at 20:15
• Yes. The procedure I'm describing will help you get the mask in the left picture more easily -- to separate the cytoplasm from the background. Think of it as giving segmentation a helping hand. – Emre Jun 24 '14 at 20:29
• Thanks, it worked great! It only took a bit of arithmetic between the channels to separate the cytoplasm from the background, without the use of color clustering. Maybe with some more work, I'll be able to get better results. – user3148616 Jun 27 '14 at 14:43