如何检测图像伪像?

发布于 2025-01-25 03:57:42 字数 819 浏览 0 评论 0原文

我需要制作脚本,如果图像包含看起来像灰色簇的视觉伪像

类型的类型,我想抓住的伪像

我用作示例的图像

目前是最好的我所拥有的想法是为HSV阴影的范围,计算非零值的范围创建掩码,并将此数量与没有伪像的样本图的类似数量进行比较:

corrupted = cv2.imread("001.jpg")
sample = cv2.imread("002.jpg")

hsv_min = np.array((0, 0, 0), np.uint8)
hsv_max = np.array((179, 7, 255), np.uint8)

hsv = cv2.cvtColor(corrupted, cv2.COLOR_BGR2HSV)
hsv2 = cv2.cvtColor(sample, cv2.COLOR_BGR2HSV)

thresh = cv2.inRange(hsv, hsv_min, hsv_max)
thresh2 = cv2.inRange(hsv2, hsv_min, hsv_max)

nz = cv2.countNonZero(thresh)
nz2 = cv2.countNonZero(thresh2)

if nz > nz2:
  print(True)

我想知道是否有特定为此,可以使用OpenCV来实现这一目标。

I need to make the script that will return True if image contains visual artifacts that look like gray clusters of pixels

Kind of artifact that I want to catch

Image I use as a sample

For now the best idea that I've got is to create a mask for the the range of hsv shades, count non-zero values and compare this amount to the similar amount of the sample-picture without the artifacts:

corrupted = cv2.imread("001.jpg")
sample = cv2.imread("002.jpg")

hsv_min = np.array((0, 0, 0), np.uint8)
hsv_max = np.array((179, 7, 255), np.uint8)

hsv = cv2.cvtColor(corrupted, cv2.COLOR_BGR2HSV)
hsv2 = cv2.cvtColor(sample, cv2.COLOR_BGR2HSV)

thresh = cv2.inRange(hsv, hsv_min, hsv_max)
thresh2 = cv2.inRange(hsv2, hsv_min, hsv_max)

nz = cv2.countNonZero(thresh)
nz2 = cv2.countNonZero(thresh2)

if nz > nz2:
  print(True)

I want to know if there is a specific tool for that or maybe the more convenient and efficient way to do that with opencv.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文