如何在python中使用skimage / opencv检测文档图像中的闪光/眩光?

请提出一种新方法或至少一种方法来使这些方法中的任何一种都足够稳健,以便以良好的速率进行检测

我有一些图像(主要是从计算机屏幕上拍摄的),其中存在某种来自相机或所谓的闪光灯。我想丢弃这些类型的图像或至少通知用户重新拍摄。我怎么能这样做?

我没有足够的资源来训练深度学习分类模型,例如 Fast Glare Detection

Here is the Data of more than 70 images

我已按顺序尝试了以下几件事:

  1. Bright area detection using OpenCV cv2.minMaxLoc function 但无论如何它总是返回该区域,并且大多数情况下它对我的图像类型失败。

  2. 我找到了 this code for removal but it is in Matlab

  3. This code uses Clahe adjustement 但问题在于它是删除而不是检测

  4. This one looks promising but is not robust enough for my image type

我发现下面的最终代码有点我需要,但有人可以帮助我使其健壮。例如,使用这些阈值/更改它们/或使用二值化、关闭(通过扩张增加白色区域,然后通过侵蚀去除黑色噪声),以便对所有人进行推广。

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

以下是一些示例:

enter image description here

如何在python中使用skimage / opencv检测文档图像中的闪光/眩光?

如何在python中使用skimage / opencv检测文档图像中的闪光/眩光?

如何在python中使用skimage / opencv检测文档图像中的闪光/眩光?

xyj_future 回答:如何在python中使用skimage / opencv检测文档图像中的闪光/眩光?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2048.html

大家都在问