OpenCV如何将图像转为灰度?

发布于 2025-01-15 22:56:11 字数 542 浏览 1 评论 0 原文

我将图像转换为灰度,然后我想知道里面发生了什么。我找到了两种可能的方式,但是里面到底发生了什么? 2种方式:

对通道进行平均

此方法涉及对像素值进行算术平均。

与通道相关的亮度感知

这是更生物学的方式。它涉及使用

0.2126 * R 值 + 0.7152 * G 值 + 0.0752 * B 值。

该方法基于人眼中存在的视锥细胞。

来源:www.kdnuggets.com

但是 OpenCV 使用什么来处理灰度呢?

I converted an image to grayscale, and then I wondered that was going on inside. I found 2 ways how it could be, but what is really going on inside?
2 ways:

Average the channels

This method involves taking the arithmetic average of the pixel values.

Сhannel-dependent luminance perception

It is more biological way. It involves the use of

0.2126 * R-value + 0.7152 * G-value + 0.0752 * B-value.

The method is based on the presence of cones in people`s eyes.

Source: www.kdnuggets.com.

But what is the OpenCV using for grayscale?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寂寞笑我太脆弱 2025-01-22 22:56:11

RGB[A] 转灰度:Y←0.299⋅R+0.587⋅G+0.114⋅B

来源:docs.opencv.org

RGB[A] to Gray:Y←0.299⋅R+0.587⋅G+0.114⋅B

Source: docs.opencv.org.

久而酒知 2025-01-22 22:56:11

有许多 ITU-R 标准定义了颜色转换。
OpenCV 使用 BT.709,你的公式是 BT.601。欲了解更多信息,请查看此处
https://mymusing.co/bt601-yuv-to-rgb-conversion -颜色/

There are many ITU-R standards that define color conversions.
OpenCV uses BT.709 and your formula is BT.601. For more check here
https://mymusing.co/bt601-yuv-to-rgb-conversion-color/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文