When I was a child, some photos were black and white. Now they are all colored and colorful. Instead, I think black and white are more pleasing to the eye. The colors are from (R (red), g (green ), B (blue) is composed of a mixture of 0 to 25 5, respectively. (R + G + B)/3, the color is black and white.
Program Simple 1 /**/ /// <Summary>
2 /// Turns a color image into a black-and-white image.
3 /// </Summary>
4 /// <Param name = "image"> Original Image </Param>
5 /// <Returns> Returned black and white photos </Returns>
6 Public Static Bitmap whiteandblack (system. Drawing. bitmap image)
7 {
8 // Original Image Length
9 Int Width = Image. width;
10 // Original Image Height
11 Int Height = Image. height;
12 // Change Pigment
13 // Abscissa
14 For ( Int X = 0 ; X < Width; x ++ )
15 {
16 // Ordinate
17 For ( Int Y = 0 ; Y < Height; y ++ )
18 {
19 // Obtain the coordinate (x, y) color.
20 Color color = Image. getpixel (x, y );
21 // Obtain the black and white color.
22 Int Value = (Color. r + Color. g + Color. B) / 3 ;
23 // Set color
24 Image. setpixel (X, Y, color. fromargb (value, value, value ));
25 }
26 }
27 Return Image;
28 }
Test results:
Source image:
Black and white: