zählt die Anzahl der schwarzen Pixel in einem Bild in Python, OpenCV

Habe ich die folgenden test-code in Python zu Lesen, Schwellenwert und zeigt ein Bild:

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()

Ich würde gerne die Anzahl der Pixel im Bild mit einem bestimmten label, zum Beispiel schwarz.
Wie kann ich das tun ? Ich sah tutorials von OpenCV fanden aber keine Hilfe 🙁

Dank!

InformationsquelleAutor Aurélie JEAN | 2015-09-15

Schreibe einen Kommentar