CLAHE is Contrast Limited Adaptive Histogram Equalization and a source in C can be found at http://tog.acm.org/resources/GraphicsGems/gemsiv/clahe.c
So far I have only seen some examples/tutorials about applying CLAHE on grayscale images so is it possible to apply CLAHE on color images (such as RGB 3 channles images)? If yes, how?
Conversion of RGB to LAB(L for lightness and a and b for the color opponents green–red and blue–yellow) will do the work. Apply CLAHE to the converted image in LAB format to only Lightness component and convert back the image to RGB. Here is the snippet. bgr is the final RGB image obtained after applying CLAHE.
Contrast limited adaptive histogram equalization (CLAHE) is used for improve the visibility level of foggy image or video. In this paper we used CLAHE enhancement method for improving the video quality in real time system.
CLAHE is a variant of Adaptive histogram equalization (AHE) which takes care of over-amplification of the contrast. CLAHE operates on small regions in the image, called tiles, rather than the entire image. The neighboring tiles are then combined using bilinear interpolation to remove the artificial boundaries.
clip-limit is the contrast limit for localized changes in contrast. A clip-limit of 2 to 3 is a good starting place (e.g. -clahe 50x50%+128+3). Very large values will let the histogram equalization do whatever it wants to do, that is result in maximal local contrast. The value 1 will result in the original image.
We can also apply CLAHE to color images, where usually it is applied on the luminance channel and the results after equalizing only the luminance channel of an HSV image are much better than equalizing all the channels of the BGR image.
Perform CLAHE on the L channel. Scale the result to get back to the range used by the L*a*b* color space. L = adapthisteq (L, 'NumTiles' , [8 8], 'ClipLimit' ,0.005); LAB (:,:,1) = L*100; Convert the resulting image back into the RGB color space. Display the original image and the processed image.
bgr is the final RGB image obtained after applying CLAHE. cv2.split isn't required as OpenCV in Python uses NumPy arrays. Once you create the CLAHE object, just do lab [...,0] = clahe.apply (lab [...,0]). You can also remove cv2.merge This method sometimes gives bad results. See point 4 of stackoverflow.com/questions/56905592/….
J = adapthisteq (I) enhances the contrast of the grayscale image I by transforming the values using contrast-limited adaptive histogram equalization (CLAHE) [1]. J = adapthisteq (I,Name,Value) uses name-value pairs to control aspects of the contrast enhancement. Apply CLAHE to an image and display the results.
Conversion of RGB to LAB(L for lightness and a and b for the color opponents green–red and blue–yellow) will do the work. Apply CLAHE to the converted image in LAB format to only Lightness component and convert back the image to RGB. Here is the snippet.
bgr = cv2.imread(image_path) lab = cv2.cvtColor(bgr, cv2.COLOR_BGR2LAB) lab_planes = cv2.split(lab) clahe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(gridsize,gridsize)) lab_planes[0] = clahe.apply(lab_planes[0]) lab = cv2.merge(lab_planes) bgr = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)
bgr is the final RGB image obtained after applying CLAHE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With