如何计算图像的对比度? [英] How to calculate the contrast of an image?
本文介绍了如何计算图像的对比度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个opencv
BGR
图像img
,如何计算该图像的对比度?
Let's say I have an opencv
BGR
image img
, how to calculate the contrast of that image?
推荐答案
One definition of contrast is RMS Contrast, it can be calculated as follows:
首先,将BGR
图像img
转换为灰度:
First, transform the BGR
image img
to greyscale:
img_grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
最后,计算灰色图像像素强度的标准偏差:
Lastly, calculate the standard deviation of the greyed image pixel intensities:
contrast = img_grey.std()
这篇关于如何计算图像的对比度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文