本文介绍了给定 RGB 值,如何创建色调(或阴影)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个 RGB 值,如 168, 0, 255,我如何创建颜色的色调(使其更亮)和阴影(使其更暗)?

Given an RGB value, like 168, 0, 255, how do I create tints (make it lighter) and shades (make it darker) of the color?

推荐答案

其中 多个选项 用于着色和着色:

Among several options for shading and tinting:

  • 对于阴影,将每个分量乘以其的 1/4、1/2、3/4 等以前的值.系数越小,阴影越深.

  • For shades, multiply each component by 1/4, 1/2, 3/4, etc., of itsprevious value. The smaller the factor, the darker the shade.

对于色调,计算(255 - 前一个值),乘以 1/4,1/2、3/4 等(因子越大,色调越淡),并将其添加到前一个值(假设 each.component 是一个 8 位整数).

For tints, calculate (255 - previous value), multiply that by 1/4,1/2, 3/4, etc. (the greater the factor, the lighter the tint), and add that to the previous value (assuming each.component is a 8-bit integer).

请注意,应在线性 RGB 中进行颜色操作(例如色调和其他阴影).然而,在文档中指定或在图像和视频中编码的 RGB 颜色不太可能是线性 RGB,在这种情况下,需要对每个 RGB 颜色分量应用所谓的逆传递函数.此功能随 RGB 色彩空间而变化.例如,在 sRGB 颜色空间(如果 RGB 颜色空间未知时可以假设),这个函数大致相当于将每个 sRGB 颜色分量(范围从 0 到 1)提高到一个幂2.2.(请注意,线性 RGB"不是 RGB 色彩空间.)

Note that color manipulations (such as tints and other shading) should be done in linear RGB. However, RGB colors specified in documents or encoded in images and video are not likely to be in linear RGB, in which case a so-called inverse transfer function needs to be applied to each of the RGB color's components. This function varies with the RGB color space. For example, in the sRGB color space (which can be assumed if the RGB color space is unknown), this function is roughly equivalent to raising each sRGB color component (ranging from 0 through 1) to a power of 2.2. (Note that "linear RGB" is not an RGB color space.)

另见紫罗兰长颈鹿关于伽马校正"的评论.

See also Violet Giraffe's comment about "gamma correction".

这篇关于给定 RGB 值,如何创建色调(或阴影)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 04:15