In Matlab, I've converted an RGB image to CIE Lab color space.
Lab = applycform(rgbImage, makecform('srgb2lab'));
L = Lab(:, :, 1);
a = Lab(:, :, 2);
b = Lab(:, :, 3);
How to quantize and combine those 3 channels?
...
For the comparison, this is what I did with RGB:
In the main program
R = rgbImage(:, :, 1);
G = rgbImage(:, :, 2);
B = rgbImage(:, :, 3);
binsR = 4;
binsG = 4;
binsB = 4;
quantR = Quantize(binsR, R, 255);
quantG = Quantize(binsG, G, 255);
quantB = Quantize(binsB, B, 255);
quantColors = (binsB*binsG*quantR) + (binsB+quantG) + quantB;
Quantize.m
function quant = Quantize(bins, data, maxdata)
quant = data * (bins/maxdata);
quant = floor(quant);
quant(quant >= (bins - 1)) = (bins - 1);
end