Skip to content

Instantly share code, notes, and snippets.

@dwy6626
Last active April 12, 2020 08:52
Show Gist options
  • Save dwy6626/f189895c7ae53664a2a04c04834c79a2 to your computer and use it in GitHub Desktop.
Save dwy6626/f189895c7ae53664a2a04c04834c79a2 to your computer and use it in GitHub Desktop.
check if the mean absolute difference to channel mean > threshold
def is_color(img, threshold=1):
"""
check if the mean absolute difference to channel mean > threshold
"""
if img.ndims < 3 or img.shape[0] == 1:
return False
avg = np.mean(img, axis=2, keepdims=True)
return np.mean(np.abs(img - avg)) > threshold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment