9

Quick question!

I have an R G B value and I want to convert to convert it to be 50% brighter. I found a gamma formula but I'm unsure if gamma is the correct way to go.

So far, I'm using:

        r = 255*((R/255.0)^ (1/1.5));
        g = 255*((G/255.0)^ (1/1.5));
        b = 255*((B/255.0)^ (1/1.5));

All I'm doing is multiplying the gamma by 1.5. The image does look brighter, but I'm unsure if its actually 50% brighter or if the formula I'm using is wrong. Is this correct?

UnseededAndroid
  • 527
  • 4
  • 8
  • 15
  • Changing gamma will make things *look* brighter by changing the brightness of the mid tones. However it won't have as much effect on the colors near black or white. It does not change brightness by a consistent amount. See https://stackoverflow.com/q/141855/5987 for a different approach. – Mark Ransom Jun 20 '18 at 19:49
  • Do you want to increase the apparent brightness (just multiply the by 1.5 for 50% increase). You could use gamma, if you want to add 50% more light (which do no appear as 50% brighter). This last method is what you should do for 3D or merging images (which requires real light). But for appearance, a simple multiplication is required. – Giacomo Catenazzi Jun 21 '18 at 10:24

1 Answers1

4

Literally "make it 50% brighter" is this

r = min(255, r*1.5)
g = min(255, g*1.5)
b = min(255, b*1.5)

You can also transform RGB to HSV map, increase the V [value] and reconvert it again to RGB.

Innuendo
  • 631
  • 5
  • 9
  • My color is pink. (255,175,175). I used that formula and i got rgb value of (255,255,255) which is white. – UnseededAndroid Jun 19 '18 at 22:15
  • 1
    I would say that it's right. What color do you expect? You have to deal with color spaces which are tricky. At the end the definition of color is also ambiguous. For instance we can take a specific value of wavelength of light to define a color. But we cannot multiply it by any number to get a "lighter" or "darker" color – Innuendo Jun 19 '18 at 22:23
  • pink is already a lot bright, so so or you maintain the hue (at maximum brightness) or you try to estimate the brightness (but so you will have white) – Giacomo Catenazzi Jun 21 '18 at 10:22
  • 3
    Convertig to HSV and increasing the V is the right way to go for the usual interpretation of "brightness". Just multiplying the numbers as above is usually not what you expect. For example blue (0,0,255) will never turn into a light blue with this method. – user74696c Apr 22 '21 at 12:42