开发者

Converting byte number to grayscale and vica versa

开发者 https://www.devze.com 2023-04-08 01:51 出处:网络
I got a number between 0-255 and need to conve开发者_如何学Crt it to a RGB grayscale color. And how do I convert a RGB-color to a grayscale value between 0-255?The common formula is luminosity = 0.30

I got a number between 0-255 and need to conve开发者_如何学Crt it to a RGB grayscale color. And how do I convert a RGB-color to a grayscale value between 0-255?


The common formula is luminosity = 0.30 * red + 0.59 * green + 0.11 * blue. Matches the human eye's color perception, doesn't otherwise correct for display device gamma.


If you have a number 0 <= x <= 255 representing a grayscale value, the corresponding RGB tuple is simply (x,x,x).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号