C # image brightness adjustment and pseudo-Color Image Processing,

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.