When the color image is converted into black and white images, it is necessary to calculate the effective brightness value of each pixel in the image, by matching pixels.
The brightness value can be easily converted to black and white images.
Calculate the pixel effective brightness value can use the following formula:
Y = 0.3red 0.59Green 0.11Blue
Then use the color.fromargb (y, y, y) to convert the calculated value.
Conversion code can be implemented using the following method:
[C #]
public
Bitmap ConvertTograscale (Bitmap Source)
{Bitmap BM = New Bitmap (Source.width, Source.Height); for (int y = 0; y