How to calculate RGB values with identical perceived brightness

I'm trying to generate RGB colors with the same perceived brightness.

The function R*0.2126+ G*0.7152+ B*0.0722 is said to calculate the perceived brightness (or equivalent grayscale color) for a given an RGB color.

Assuming we use the interval [0,1] for all RGB values, we can calculate the following:

  • yellow = RGB(1,1,0) => brightness=0.9278
  • blue = RGB(0,0,1) => brightness=0.0722
  • So, in order to make the yellow tone just as dim as the blue one i can simply perform this simple calculation on yellow for each of the RGB components:

  • dim_yellow = yellow * 0.0722 / 0.9278
  • However, when doing the opposite thing, thus "scaling" up the blue color to the same perceived brightness as the original yellow, the B component obviously exceeds 1, which cannot be displayed on a computer screen.

    I guess the missing brightness from the excess B component could be "redistributed" to the R and G components, faking a brighter blue color. So what is the best general method to calculate those final RGB values?


    I recommend you to use HSV color model instead of RGB since you can easily achive what you want only modifying Value(Brightness) component. The wiki page also contains how to convert RGB to HSV and back

    EDIT: Try to use CIELAB color space since it approximate human's vision

    链接地址: http://www.djcxy.com/p/87034.html

    上一篇: JS函数计算互补色?

    下一篇: 如何计算亮度相同的RGB值