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