View Full Version : Make a Bitmap B&W
noblerare
Nov1-09, 10:28 PM
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
hamster143
Nov2-09, 12:26 AM
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.
DavidSnider
Nov2-09, 01:01 AM
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.
That's interesting. Is there some explanation behind the magic numbers?
hamster143
Nov2-09, 02:22 AM
That's interesting. Is there some explanation behind the magic numbers?
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.
noblerare
Nov3-09, 10:59 AM
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?
DavidSnider
Nov3-09, 11:15 AM
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?
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;
ApexOfDE
Nov4-09, 04:28 AM
this link (http://www.switchonthecode.com/tutorials/csharp-tutorial-convert-a-color-image-to-grayscale) may give you some idea about this.
vBulletin® v3.7.6, Copyright ©2000-2009, Jelsoft Enterprises Ltd.