1.5.15.1. fejezet, Üres kép detektálása

import numpy as np
import cv2
 
blank_image2 = np.zeros((100,100,3), dtype=np.uint8)
cv2.imwrite("result.jpg", blank_image2)
 
def is_empty(img):
   # Reading Image
   image = cv2.imread(img, 0)
   np.reshape(image, (-1,1))
   u, count_unique = np.unique(image, return_counts =True)
 
   if count_unique.size< 10:
      return "Image is empty"
   else:
      return "Image is not empty"
 
print(is_empty('align.png')) #not empty
print(is_empty('result.jpg')) #empty