如何检测图像伪像?
我需要制作脚本,如果图像包含看起来像灰色簇的视觉伪像
目前是最好的我所拥有的想法是为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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论