For example I have a pixel with these values:
CGFloat red = 34 // 0 - 255
CGFloat green = 128
CGFloat blue = 190
and I want to increase luminance so that blue is 255. NOTE: With "Luminance" I mean the L-component of Photoshop in LAB color space. See pictures!
There must be a special formula to compute the RGB values for the increased luminance, because the R G B values are modified in a non-linear way!
Proof: I did a test in Photoshop and created this same color, and then opened the color picker to examine it:
Then I activated the L component of the LAB color space, which controls luminance (at least that is what I am talking about - I mean the brightness controlled by that L component. Guess that is luminance).
So with L activated, I dragged the slider on the left upwards until B reached 255:
Now read the resulting R G B values:
CGFloat newRed = 112 // 0 - 255
CGFloat newGreen = 188
CGFloat newBlue = 255
The differences between these is:
newRed - red = +78
newGreen - green = +60
newBlue - blue = +65
The percentages are:
red shift: +38.42%
green shift: +29.55%
blue shift: +32.01%
This does not correspond with the known formula for computing Luminance out of R G B, which is something close to luminance = (red * 0.3) + (green * 0.6) + (blue * 0.1)
.
Obviously, they have been shifted in a non-linear manner.
Is there a known way to compute newRed, newGreen, newBlue out of red, green, blue in a similar fashion how Photoshop does it?