Reputation: 387
I'd like to count the number of pixels with the value=[0,100,234] in an image.
Without using loops over the image, could you please propose a method of how to determine the number of these particular pixels?
Upvotes: 5
Views: 9225
Reputation: 41775
To count the number of pixels with the value = [0,100,234]
you can use:
np.count_nonzero((img == [0, 100, 234]).all(axis = 2))
Upvotes: 9