Browse Source

add is_solid_color_image

quarrying 2 years ago
parent
commit
a3d8f5e0a4
1 changed files with 7 additions and 0 deletions
  1. 7 0
      khandy/image/misc.py

+ 7 - 0
khandy/image/misc.py

@@ -218,3 +218,10 @@ def is_gray_image(image, tol=3):
     else:
         return False
         
+
+def is_solid_color_image(image, tol=4):
+    assert is_numpy_image(image)
+    mean = np.array(cv2.mean(image)[:-1], dtype=np.float32)
+    mae = np.mean(np.abs(image - mean))
+    return mae <= tol
+