MATLAB: Problems with adapthisteq and RGB converted to LAB space

adapthisteq rgb labImage Processing Toolbox

Hi, I have a problem processing an RGB image with adapthisteq using the LAB colorspace to process luminosity layer of L*a*b* and then converting back to RGB.
I have done it well directly processing R,G,B channels separately or processing intensity component of the converted HSV image but I canĀ“t get it work converting the image to LAB color space. It works with an Indexed image but not with an RGB image. This is the code:
img = imread('Photo.tif');
%# process luminosity layer of L*a*b*, then convert back to RGB
LAB = applycform(img, makecform('srgb2lab'));
L = LAB(:,:,1)/100;
LAB(:,:,1) = adapthisteq(L,'NumTiles',[8 8],'ClipLimit',0.005)*100;
cform2srgb = makecform('lab2srgb');
J = applycform(LAB, cform2srgb);
figure, imshow(img);
figure, imshow(J);
Why is failing within the LAB colorspace? Thanks!

Best Answer

I think I have found the answer from the manual: "The Image Processing Toolbox software follows the convention that double-precision L*a*b* arrays contain 1976 CIE L*a*b* values. L*a*b* arrays that are uint8 or uint16 follow the convention in the ICC profile specification (ICC.1:2001-4, www.color.org) for representing L*a*b* values as unsigned 8-bit or 16-bit integers".
So If i convert the LAB image in uint format to double format with "lab2double", adapthisteq works well.