计算中位数/模式,但忽略黑色

时间:2019-04-23 21:35:51

标签: python numpy opencv

在OpenCV Python中,我屏蔽了图像的某些部分,因此它们是黑色的。我需要计算图像中出现的中值(或众数)颜色,但忽略蒙版/黑色像素。

如何执行此操作,因为我使用的功能仍会考虑黑色像素AFAIK:

mode = scipy.stats.mode(img) # will consider black pixels wont it?
median = np.median(img, axis=(0,1)) # will consider black pixels wont it?

0 个答案:

没有答案
相关问题