RGB to Grayscale Conversion Calculator

You can use this RGB to Grayscale conversion calculator to transform RGB values to their corresponding grayscale values.

RGB to Grayscale Converter

How to Convert Between RGB and Grayscale

The RGB color model is used to describe the way in which colors in different hues and tones are displayed by differing the amount of red, green, and blue light that is displayed through the pixels. The pure form of red, green, and blue are displayed as follows:


This pure form of display is represented by the following encoding: pure red (255, 0, 0), pure green (0, 255, 0), and pure blue (0, 0, 255).

When RGB encodings are presented, the first value always represents the amount of red, the second the amount of green, and the third the amount of blue. A range between 0 and 255 is used in the encodings.

Grayscale images do not include any color. They are given in the range of shades that lie between black and white. For example, white is represented by 255, 255, 255, black is represented by 0, 0, 0, and medium gray is 127, 127, 127. The higher the number is, the lighter the gray becomes. RGB encodings can be converted to grayscale values by converting the RGB encoding into a set of three equal numbers that represent the range on the black-white spectrum on which the color appears.

To transform a color into its corresponding grayscale value, you need to calculate the average of the R, G, and B values using a weighted approach.

Equation for Converting RGB to Grayscale

The grayscale weighted average, Y, is represented by the following equation:

Y = 0.299 R + 0.587 G + 0.114 B

Where R, G and B are integers representing red (R), green (G) and blue (B) with values in the range 0–255.

It is important to note that the colors are not equally weighted. As pure blue is darker than pure red and pure green, it is allocated the least weight.

Computation Example: Let's say we have a color that can be represented by the RGB value 70, 130, 180. The weighted average for our RGB color (70, 130, 180) is as follows:

Y = 0.299(70) + 0.587(130) + 0.114(180),

When the weighted average does not equate to a whole number, we round it to the nearest whole. As such, our computed equivalent gray is Y=118 (118, 118, 118).

Some examples of RGB encodings and their equivalent grayscale values are presented below.

Pure Red (255,0,0) Equivalent Gray (76, 76, 76)
Pure Green (0, 255, 0) Equivalent Gray (150, 150, 150)
Pure Blue (0, 0, 255) Equivalent Gray (29, 29, 29)
Yellow (255, 255, 0) Equivalent Gray (226, 226, 226)
Magenta (255, 0, 255) Equivalent Gray (105, 105, 105)
Cyan (0, 255, 255) Equivalent Gray (179, 179, 179)
Maroon (128, 0, 0) Equivalent Gray (38, 38, 38)

You may also be interested in our free RGB <-> Hex Conversion Calculator

Rating: 4.2/5 (219 votes)