什么是用于调节亮度的颜色矩阵?

发布于 2024-10-31 03:02:53 字数 115 浏览 4 评论 0原文

搜索周围有很多关于将图像转换为亮度(黑白)或调整饱和度而不改变亮度的信息。但如何修改亮度本身呢?例如,如何使用 5x5 矩阵增加红色通道亮度?最终这将在 C 中使用,但相同的数学应该适用于 java 或 flash。

Searching around there is lots of information on converting an image to luminance (B&W) or adjusting saturation w/out changing luminance. But how can you modify luminance itself? For instance, how can I increase the red channel luminance using a 5x5 matrix? Ultimately this will be used in C but the same math should work w/java or flash.

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

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

发布评论

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

评论(2

纵情客 2024-11-07 03:02:53

对于从 google 来到这里的任何人,这里是缩放亮度的矩阵:

rl×l + gl + bl    gl×l - gl         bl×l - bl         0
rl×l - rl         gl×l + rl + bl    bl×l - bl         0
rl×l - rl         gl×l - gl         bl×l + rl + gl    0
0                 0                 0                 1

其中

  • l - 亮度乘数,
  • rl - 红色亮度(sRGB 为 0.213),
  • gl — 绿色亮度(sRGB 为 0.715),
  • bl — 蓝色亮度(sRGB 为 0.072)。

请注意:此矩阵可能很容易产生色域外的颜色,因此当您期望获得准确的结果时,请勿使用它。例如,对于 1, 0, 0, 1 向量和 l=2 它将产生 1.213, 0.213, 0.213, 1 结果。从技术上讲,该矢量具有预期的亮度 (0.426),但显示的颜色将约为 0.381。

For anyone who came here from google, here is the matrix to scale luminance:

rl×l + gl + bl    gl×l - gl         bl×l - bl         0
rl×l - rl         gl×l + rl + bl    bl×l - bl         0
rl×l - rl         gl×l - gl         bl×l + rl + gl    0
0                 0                 0                 1

where

  • l — luminance multiplier,
  • rl — red luminance (0.213 for sRGB),
  • gl — green luminance (0.715 for sRGB),
  • bl — blue luminance (0.072 for sRGB).

Please note: this matrix may easily produce out of gamut colors, so don’t use it when you expect accurate results. For example, for the 1, 0, 0, 1 vector and l=2 it will produce the 1.213, 0.213, 0.213, 1 result. Technically, this vector has the expected luminance (0.426), but the displayed color will be ≈0.381.

窗影残 2024-11-07 03:02:53

我相信你同样改变所有三个颜色值,所以......

要缩放 RGB 颜色,使用这样的矩阵:

float mat[4][4] = {
    rscale, 0.0,    0.0,    0.0,
    0.0,    gscale, 0.0,    0.0,
    0.0,    0.0,    bscale, 0.0,
    0.0,    0.0,    0.0,    1.0,
};

来自: http://www.graficaobscura.com/matrix/index.html

I believe you change all three color values equally so...

To scale RGB colors a matrix like this is used:

float mat[4][4] = {
    rscale, 0.0,    0.0,    0.0,
    0.0,    gscale, 0.0,    0.0,
    0.0,    0.0,    bscale, 0.0,
    0.0,    0.0,    0.0,    1.0,
};

From: http://www.graficaobscura.com/matrix/index.html

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