www.gusucode.com > images 案例代码 matlab源码程序 > images/ApplyCLAHEToAColorImageExample.m

    %% Apply CLAHE to a color image
% 
%%
% Read the color image into the workspace.
[X, MAP] = imread('shadow.tif');
%%
% Convert the indexed image into a truecolor (RGB) image.
RGB = ind2rgb(X,MAP); 
%%
% Convert the RGB image into the L*a*b* color space.
LAB = rgb2lab(RGB);
%%
% Scale values to the range expected by the |adapthisteq| function, |[0
% 1]|.
L = LAB(:,:,1)/100; 
%%
% Perform CLAHE. Multiply the result to get back to the range used by the
% L*a*b* color space.
LAB(:,:,1) = adapthisteq(L,'NumTiles',...
                         [8 8],'ClipLimit',0.005)*100;
%%
% Convert the resultant image back into the RGB color space.
J = lab2rgb(LAB);
%%
% Display the original image and result.
figure, imshow(RGB); 
figure, imshow(J);