美文网首页
sRGB 2023-04-24

sRGB 2023-04-24

作者: 9_SooHyun | 来源:发表于2023-04-23 15:19 被阅读0次

    红蓝绿三元光这理论并不是因为这三个波长的光很特殊,而是我们人眼恰好只能看这三种波长并且赋予了颜色,打个比方如果喵星人是智慧生物那么他们色彩模型就不是RGB(红绿蓝)而是RB(红蓝)

    sRGB

    Whenever a pixel is captured in some way (cameras, scanners, etc.) it is often captured with a higher dynamic range than 8 bits can provide. However, eyes are very much nonlinear and are much better seeing differences in darker colors than they are in lighter colors, so these colors are effectively put in a lossy compression algorithm called sRGB.

    Whenever a color is displayed on a screen or printed, it is again decompressed with hopefully the same algorithm to get a close approximation of the original color back - and you probably can't tell the difference.

    sRGB逼近的是人眼的视觉感光量,它给予低亮度更多的编码,同时高亮度区更少的编码(相对而言,人对黑暗比光亮更加敏感).
    sRGB的值符合人的视觉,是给人看的,不是给显示器看的。显示器需要展示图像,需要从人的视觉值(sRGB value)转换成物理上的线性值

    sRGB value

    Each of the red, green and blue light levels is encoded as a number in the range 0-255, with 0 meaning zero light and 255 meaning maximum light.

    The red, green, and blue values in a sRGB color texture are encoded and cannot be modified directly.
    Modifying them directly would be like running spellcheck on an encrypted message. Before you can run spellcheck, you first have to decrypt the message. Similarly, to modify the values of an sRGB texture, you first have to decode or transform them to RGB or linear color space.

    sRGB to linear

    If you want to do correct blending between two colors, here is what you'll need to do:

    • Decode both colors from sRGB to linear. Linear colors are often stored in a set of floating point numbers but you could also use 32-bit integers if that is faster on some hardware (think embedded devices without FPU).
    • Blend the two colors together in whatever way you like, as you would otherwise do naively.
    • Encode the resulting color again into sRGB(0-255).

    So if you want to know the linear value for rgb(127, 127, 127), that's Math.pow(127/255, 2.2) is about 21.6%. And back again: Math.pow(0.216, 1/2.2)*255 equals about rgb(127, 127, 127). For non-gray colors, simply apply this formula to each component individually.

    相关文章

      网友评论

          本文标题:sRGB 2023-04-24

          本文链接:https://www.haomeiwen.com/subject/lucyjdtx.html