'How can I detect image artifacts?
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
