kiriloff
kiriloff

Reputation: 26333

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, s.t. r==b==g. Why?

Thanks a lot! Regards.

Upvotes: 0

Views: 1334

Answers (2)

Stefan van der Walt
Stefan van der Walt

Reputation: 7253

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, i.e.

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).

Upvotes: 3

dorsh
dorsh

Reputation: 24740

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

Upvotes: 3

Related Questions