直接上代码吧:
import cv2
import numpy as np
from PIL import Image area =
def getWhitePixel(img):
global area
image=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(image,(,),)
ret3,th3 = cv2.threshold(blur,,,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
height, width = th3.shape
for i in range(height):
for j in range(width):
if th3[i, j] == :
area +=
return area