compter le nombre de pixels noirs dans une image en Python avec OpenCV

J'ai de la suite de test de code en Python pour lire, le seuil et l'affichage d'une image:

import cv2
import numpy as np 
from matplotlib import pyplot as plt

# read image
img = cv2.imread('slice-309.png',0)
ret,thresh = cv2.threshold(img,0,230, cv2.THRESH_BINARY)
height, width = img.shape
print "height and width : ",height, width
size = img.size
print "size of the image in number of pixels", size 

# plot the binary image
imgplot = plt.imshow(img, 'gray')
plt.show()

Je voudrais compter le nombre de pixels dans l'image avec une certaine étiquette, par exemple, noir.
Comment puis-je le faire ? J'ai regardé des tutoriels de OpenCV, mais n'a trouvé aucune aide 🙁

Merci!

OriginalL'auteur Aurélie JEAN | 2015-09-15