title: How can I detect image artifacts?
body: <p>I need to make the script that will return True if image contains visual artifacts that look like gray clusters of pixels</p>
  <p><a href="https://i.stack.imgur.com/VtqkZ.jpg" rel="nofollow noreferrer">Kind of artifact that I want to catch</a></p>
  <p><a href="https://i.stack.imgur.com/s0sAx.jpg" rel="nofollow noreferrer">Image I use as a sample</a></p>
  <p>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:</p>
  <pre><code>corrupted = cv2.imread(&quot;001.jpg&quot;)
  sample = cv2.imread(&quot;002.jpg&quot;)
  
  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 &gt; nz2:
    print(True)
  </code></pre>
  <p>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.</p>