简体   繁体   English

如何计算python opencv中某些像素值的像素数

[英]how to count number of pixels wit certain pixel value in python opencv

I'd like to count the pixels with the value=[0,100,234] of an image. 我想用图像的值= [0,100,234]计算像素。

Without using loops over the image, could you please propose a method how to determine the number of these particular pixels? 如果不在图像上使用循环,您能否提出一种方法来确定这些特定像素的数量?

要计算值= [0,100,234]的像素数,您可以使用:

np.count_nonzero((img == [0, 100, 234]).all(axis = 2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM