Home » Community » Forums » General Programming » getting brightness from RGB tuple?
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 getting brightness from RGB tuple?
Post New Topic  Post Reply 
I am trying to analyze brightness of a picture, but I have no idea how to extract the brightness value given the Red, Green, Blue tuple... Does anyone know of some kind of formula or method to do this? I am working in Python.

 User Rating: 1008   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I'm not sure if this is what you need but you can calculate the luminance of a pixel with this formula:

Luminance = (0.2126*R) + (0.7152*G) + (0.0722*B)

Good Luck,
David

 User Rating: 1037   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

that worked like a charm! thank you

 User Rating: 1008   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

You can also simply use (R+G+B) / 3. The true brightness is monitor dependent anyway. Though win_crook is right that the eye is much more sensitive to green than to blue.

 User Rating: 1459   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by Lode
You can also simply use (R+G+B) / 3. The true brightness is monitor dependent anyway. Though win_crook is right that the eye is much more sensitive to green than to blue.

That's a formula for lightness. It has its place in the world, but when determining perceived lightness of an image (say, for HDR) it's always best to go with the weighted mean (as they both amount to a dot-product). There are indeed a few standards, and they disagree when used on different display devices, but they are all in the same ball-park.

Lightness, perceived lightness, brightness, luminance and intensity are all different things (some more subtly than others), and give rise to different formulas. In the situation, though, we're talking about either luminance or perceived lightness and it would be a crime to equally weigh the three colour components . I find this reference invaluable for these finicky matters.

Admiral

 User Rating: 1679   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: