Brightness from RGB value

Monkey Forums/Monkey Programming/Brightness from RGB value

Raz(Posted 2011) [#1]
I am writing a colour class that also stores the Hue, Brightness and Saturation (which in turn can be changed to alter the Red Green and Blue values).

Using Paint.Net (graphics package) as a comparision I've got the Hue and Saturation part sorted. However the Brightness is not quite right.

Paint.Net RGB | Paint.Net HSB | MyHSB
-------------------------------------
163           | 21            | 21
128           | 33            | 33
109           | 63            | 52


All reading I've found suggests there are different ways of working it out but the formula I've been using is...

nBri = (0.2126*r) + (0.7152*g) + (0.0722*b)


which doesn't match. So I am wondering, how would you all calculate the brightness from red green and blue?


Virtech(Posted 2011) [#2]
Try this

brightness = Sqr( (.241*(r*r)) + (.691*(g*g)) + (.068*(b*b)) )



Raz(Posted 2011) [#3]
Thanks Virtech :) Is that the recommended way of working out brightness?