简体   繁体   中英

Python PIL - RGB pixel values for b&w pixel

I would like to know whether a pixel in a b&w part of a RGB image is characterized by parameters r,g,b, st r==b==g. Why?

Thanks a lot! Regards.

The RGB codes of the grayscale colors (white-grays-black) consist of the same byte three times. Black is 0-0-0, white is 255-255-255, etc.

Read more here: http://en.wikipedia.org/wiki/Grayscale

The conversion formula, from RGB to grey, is

L = 0.2125 * R + 0.7154 * G + 0.0721 * B

That means that there are multiple colours that can produce a single grey value. To see why this is the case, imagine the formula had equal weights, ie

L = 0.333 * R + 0.333 * G + 0.333 * B = 1/3 * (R + G + B)

then L=100 could be produced by (R=0,G=150,B=150) or (R=150,G=0,B=150).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM