# Make a Bitmap B&W

1. Nov 1, 2009

### noblerare

Hi,

I was recently introduced to image manipulations and bit processing in my C programming class. I am pretty interested in the many creative ways an image can be encrypted and manipulated.

I was wondering, does anyone know of a way to change a given bitmap into a black and white rendition of the original colored image?

What do we do to the bytes?

Thanks!

Samuel

2. Nov 1, 2009

### hamster143

The easy way is to take an average.

The more advanced way is to weigh them as R*0.299 + G*0.587 + B*0.114, this would result in a better approximation of apparent brightness.

3. Nov 2, 2009

### DavidSnider

That's interesting. Is there some explanation behind the magic numbers?

4. Nov 2, 2009

### hamster143

I don't know all the details, but these are the standard coefficients used to convert RGB to YUV, and presumably they are based on sensitivity of the human eye to different bandwidths. These numbers are present in ITU-R recommendation 601 (dating to 1982) and they are most likely older than that, possibly as old as color television.

5. Nov 3, 2009

### noblerare

So are you saying that if I take the average of the RGB values in each pixel and assign the average to each RGB value, that I would get a B&W rendition of the original image?

How exactly does that work?

6. Nov 3, 2009

### DavidSnider

Try thinking of it this way: A color picture is 3 layers of greyscale images that specify the red green and blue components. All you are doing is taking a weighted average of the layers.

Average = Original.R*0.299 + Original.G*0.587 + Original.B*0.114;
New.R = Average ; New.G = Average ; New.B = Average;

7. Nov 4, 2009

### ApexOfDE

Last edited by a moderator: Apr 24, 2017