如何计算图像的对比度? [英] How to calculate the contrast of an image?

查看:2252
本文介绍了如何计算图像的对比度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆