Please suggest a new approach or at least a method to make any of these robust enough to detect at good rate
I have some images (mostly taken from computer screen) where some kind of flash from camera or so called is present there. I want to discard these type of images or at least notify the user to retake it. How could I do that?
I do not have enough to train a Deep Learning Classification model such as Fast Glare Detection
Here is the Data of more than 70 images
I have tried these few things in order:
Bright area detection using OpenCV
cv2.minMaxLocfunction but it ALWAYS returns the area no matter what and mostly it fails for my type of images.This code uses
Claheadjustement but the problem is that it removes rather than detectionThis one looks promising but is not robust enough for my image type
The final below code I found is somewhat I need but can someone help me for making it robust. for example using these thresholds / changing them / or using Binarization , Closing (Increasing White area with dilation and then removing black Noise with Erosion) such that these are generalised for all.
def get_image_stats(img_path):
img = cv2.imread(img_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (25, 25), 0)
no_text = gray * ((gray/blurred)>0.99) # select background only
no_text[no_text<10] = no_text[no_text>20].mean() # convert black pixels to mean value
no_bright = no_text.copy()
no_bright[no_bright>220] = no_bright[no_bright<220].mean() # disregard bright pixels
std = no_bright.std()
bright = (no_text>220).sum()
if no_text.mean()<200 and bright>8000:
return True
These are some of few examples:


