Lighting problems are common and difficult. How does one detect and reduce light reflection to save more information from an image? I have tried several methods with OpenCV and Python without luck.
(Image with reflection)
(Image without reflection)
I tried converting to HSV color space, and apply Histogram Equalization to the V channel, with Clahe equalization:
import cv2
import numpy as np
image = cv2.imread('glare.png')
hsv_image = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
h, s, v = cv2.split(hsv_image)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
v = clahe.apply(v)
hsv_image = cv2.merge([h, s, v])
hsv_image = cv2.cvtColor(hsv_image, cv2.COLOR_HSV2RGB)
cv2.imwrite('clahe_h.png', hsv_image)
results:
As well I tried thresholding to find bright pixels and than use Image Inpainting to replace them with neighbouring pixels.
import cv2
import numpy as np
image = cv2.imread('glare.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3,3), 0)
thresh = cv2.threshold(blurred, 225, 255, cv2.THRESH_BINARY)[1]
dst_TELEA = cv2.inpaint(image,thresh,3,cv2.INPAINT_TELEA)
cv2.imwrite('after_INPAINT.png',dst_TELEA)