Last active
April 12, 2020 08:52
-
-
Save dwy6626/f189895c7ae53664a2a04c04834c79a2 to your computer and use it in GitHub Desktop.
check if the mean absolute difference to channel mean > threshold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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