The color distortion observed in the example of the previous section was caused by the high correlation between the R, G, and B channels in the case of the RGB image. This is another reason, why in many cases, a safer choice of color channel for color image processing tasks is CIE-L*a*b*. Let's try to alter the function written in the previous section, so that it converts the RGB input image to the CIE-L*a*b* color space, apply the chosen enhancement method only in the Lightness channel (so that the colors remain unaffected) and then transform the resulting image back to RGB:
function output = ColorContrastEnhanceLab(input, method) % Function for color contrast enhancement of input image in L*a*b* % Inputs: % input - Input image % method – Enhancement method selection (0: histeq % 1: adapthisteq % 2: imadjust) % Output: % output - Output image (enhanced) cform = makecform('srgb2lab'); % Make the transform structure img_lab = applycform(input...