Benchmark algorithm to change perceptive brightness?
What is the benchmark algorithm to change perceptive brightness of an RGB pixel. such as:
if I have RGB (120, 33, 213) then ( ... using ... (0.299*R + 0.587*G + 0.114*B) ....) i get 79.533 as perceptive brightness but I do not have a way to raise the brightness of the same pixel to 80 as there are many possible values for it.
I have searched for solution for a while but could not get it. There are some algorithms to calculate the brightness such as:
Formula to determine brightness of RGB color
But these algorithms are not reversible.
Also, I am not considering using HSL or HSV as a correct approach unless somebody can correct me?
Edit: using HSL color space I am able to control the brightness while preserving the color to a great extent but I am wondering if there is a better approach.
Thanks-
You don't need to reverse the luminance equation, you just have to figure out the ratio to your desired luminance.
From your example:
//target luminance = 80
srcR = 120
srcG = 33
srcB = 213
srcLum = 79.533
destLum = 80
ratio = (destLum / srcLum) = 1.0058717...
destR = (srcR * ratio) = 120.705
destG = (srcG * ratio) = 33.194
destB = (srcB * ratio) = 214.251
You'll have to decide how you want to round them to get int values, but that's the general idea. Going from 79.5 to 80 isn't much of a change, though, so you won't see much. If you were going to 40, you'd end up with RGB(60,17,107).
As Mark Ransom points out below, once one of your values hits 255, you'll have to make a choice. To increase the luminance past that point, you'll either be changing the hue or the saturation(or both). His answer here shows the difference between the two quite well.
链接地址: http://www.djcxy.com/p/87030.html上一篇: 如何计算RGB颜色中颜色分量的“量”
下一篇: 基准算法改变感知亮度?