C # image brightness adjustment and pseudo-Color Image Processing,
The left is the effect, the right is the principle, the right X axis represents the gray level of an image pixel, and the Y axis represents the pseudo-color of RGB three colors. The Code is as follows:
For (int y = 0; y
{
For (int x = 0; x <width; x ++)
{
Color c = bmp. GetPixel (x, y );
Int R = c. R; int G = c. G; int B = c. B;
Byte temp = (byte) (B * 0.114 + G * 0.587 + R * 0.299 );
If (temp> = 0 & temp <= 63)
{
Bmp. SetPixel (x, y, Color. FromArgb (0, (byte) (4 * temp), (byte) 255 ));
}
If (temp> = 64 & temp <= 127)
{
Bmp. SetPixel (x, y, Color. FromArgb (0,255, (byte) (510-4 * temp )));
}
If (temp> = 128 & temp <= 191)
{
Bmp. SetPixel (x, y, Color. FromArgb (byte) (4 * temp-510), 255, 0 ));
}
If (temp> = 192 & temp <= 255)
{
Bmp. SetPixel (x, y, Color. FromArgb (255, (byte) (1022-4 * temp), 0 ));
}
}
}
Image brightness adjustment:For (int y = 50; y <100; y ++)
{
For (int x = 50; x <100; x ++)
{
// Process the brightness of pixels at the specified position
Color c = B. GetPixel (x, y );
Int R = c. R; int G = c. G; int B = c. B;
R = R + degree; if (R> 255) R = 255;
G = G + degree; if (G> 255) G = 255;
B = B + degree; if (B> 255) B = 255;
B. SetPixel (x, y, Color. FromArgb (R, G, B ));
}
} // Where degree is the brightness tier