img = cv2.imread('bgr.png')
BLUE_MIN = np.array([0, 0, 200], np.uint8)
BLUE_MAX = np.array([50, 50, 255], np.uint8)
dst = cv2.inRange(img, BLUE_MIN, BLUE_MAX)
no_blue = cv2.countNonZero(dst)
print('The number of blue pixels is: ' + str(no_blue))
cv2.namedWindow('opencv')
cv2.imshow('opencv', img)
cv2.waitKey(0)
Calculating the number of blue pixels in a picture