How do I remove artifacts created by CLAHE algorithm?

I have taken the Lena image and applied CLAHE transformation on the Value component (using HSV transformation) of the image. As can be seen from the image there are some artifacts that are due to the tiles used in CLAHE.


import cv2 as cv
def pcnn_4(img):
    hsv_img = cv.cvtColor(img, cv.COLOR_RGB2HSV)
    h, s, v = cv.split(hsv_img)
    clahe = cv.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
    contrast_enhanced_img = clahe.apply(v)
    return contrast_enhanced_img

img = cv.imread('lena15.jpg')
result_img = pcnn_4(img)
cv.imshow('image', result_img)

Original Image:

_ (I can’t share the link directly as I am a new user)

I found this on OpenCV 's website

After equalization, to remove artifacts in tile borders, bilinear interpolation is applied.

I am not too sure on how bilinear interpolation should be applied. I tried downsizing the image using bilinear interpolation, but that does not help.

I need help on how I could apply bilinear interpolation to remove these artifacts. Any other techniques are also welcome.

please show code.

did you try different block sizes ?
any chance, you have a jpg as input ?

all i’m saying is: jpg’s also have 8x8 block artefacts, which horribly interfere with things like CLAHE, if you chose 8x8 blocks there
in general, you should try to avoid jpgs for image processing

this is already done internally

1 Like