RGB and grayscale conversion algorithms

Source: Internet
Author: User

What is a grayscale image? Any color is composed of three primary colors: red, green, and blue. If the color of a certain point is RGB (R, G, B), we can use the following methods, convert it to grayscale:

1. Floating point algorithm: Gray = R * 0.3 + G * 0.59 + B * 0.11

2. Integer method: Gray = (R * 30 + G * 59 + B * 11)/100

3. Shift method: Gray = (R * 76 + G * 151 + B * 28)> 8;

4. Average method: Gray = (R + G + B)/3;

5. Green only: Gray = G;

After obtaining the Gray using any of the above methods,

Replace R, G, and B in the original RGB (R, G, B) with Gray,

New colors: RGB (Gray, Gray, Gray ),

Replacing the original RGB (R, G, B) with it is a grayscale image.

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.