OF: need to calculate a valid luminance value per pixel image when converting a color image to a monochrome image is unknown, by matching pixel
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 [Vb] Public Function ConvertTograscale () Function ConvertTogramyScale (Byval Source As Bitmap) AS Bitmap Dim BM As New Bitmap (Source.width, Source.Height) Dim x Dim y for y = 0 to bm.height for x = 0 To bm.width Dim C as color = Source .Getpixel (x, y) DIM LUMA AS INTEGER = CINT (CR * 0.3 CG * 0.59 CB * 0.1) BM.Setpixel (x, y, color.fromargb (luma, luma, luma) Next Next Return Bmend Function Of course, this is a good method. If you need more simple color conversion, you can use the ColorMatrix class.