3 ms·
The big takeaway here is that you should never perform brightness arithmetic on sRGB. You need to remove gamma to make brightness linear, do your math, then re-
by crazygringo 7y ago
The big takeaway here is that you should never perform brightness arithmetic on sRGB. You need to remove gamma to make brightness linear, do your math, then re-apply gamma.
The full correct formula is:
https://stackoverflow.com/a/13558570 https://stackoverflow.com/a/13558570
Interestingly gamma correction also includes a linear component. For more info on why:
https://poynton.ca/notes/colour_and_gamma/GammaFAQ.html#gamma_correction https://poynton.ca/notes/colour_and_gamma/GammaFAQ.html#gamm...
- raphlinus 7y agoI have actually seen a lot of different explanations why the sRGB EOTF has a linear part, and can come up with a few more theories myself. In the Poynton FAQ, it says it "minimizes the effect of sensor noise in practical cameras and scanners". Wikipedia says "The purpose of the linear section is so the curve does not have an infinite slope at zero, which could cause numerical problems." Poynton's book Digital Video and HD: Algorithms and Interfaces talks about "veiling glare" and then says that the sRGB function almost perfectly inverts L* from the CIELAB color space (a pure 2.2 gamma would not do so). His thesis[1] goes into more detail. One possible theory why there's a linear term is so that negative values are well-defined. In consumer HDMI, reference black is 10 (as opposed to 0 in sRGB), and reference white is 235 (as opposed to 255 in sRGB). Since there no doubt be experts here, I'd love to see an authoritative answer. (I'm considering writing an explanation of sRGB and if so would really like to get this right) [1]: http://poynton.ca/PDFs/Poynton-2018-PhD.pdf http://poynton.ca/PDFs/Poynton-2018-PhD.pdf
- Ono-Sendai 7y agoOne possible reason is that it's hard to construct a numerical approximation (e.g. polynomial approximation) to the power curve around zero. With a linear part you avoid that problem. This is probably what the 'numerical problems' alludes to.
- crazygringo 7y agoOh wow, I had no idea about video black/white being 16/235, rather than 0/255. It took a lot of Googling, but I finally found an article that explains why, in case anyone else is interested: "The 601 system allows colors that are darker than black and brighter than white. This is especially important for cameras, because you may occasionally shoot an object that has a bright spot that is “hotter” than legal white, and might want a way to later recover the detail in this hot spot. Going darker than broadcast black is also used at times for synchronization signals, as well as some primitive keying applications such as “superblack” where systems mask or key out areas of an image “blacker” than black." https://www.provideocoalition.com/luminance_ranges/ https://www.provideocoalition.com/luminance_ranges/
- Fronzie 7y agoThere's also a pragmatic reason: When sampling the PAL/NTSC signal cabling will have applied low-pass filtering, causing over- and under-shoot of the signal. By setting the signal up to have the range 16/235 for an 8-bits A/D converter, this overshoot does not saturate the A/D converter. Lots of consumer electronics is designed with these kind of rules.
- 0x00000000 7y agoFun fact the blender cycles renderer used sRGB for a long time which was just throwing away huge amounts of dynamic range
- a_e_k 7y agoFrom the original 1996 proposal "A Standard Default Color Space for the Internet - sRGB" (https://www.w3.org/Graphics/Color/sRGB https://www.w3.org/Graphics/Color/sRGB): > The effect of the above equations is to closely fit a straightforward gamma 2.2 curve with an slight offset to allow for invertability in integer math. Therefore, we are maintaining consistency with the gamma 2.2 legacy images and the video industry as described previously.
- raphlinus 7y agoRight, should have added that to the list of not-quite-consistent explanations. Also, slight typo, black level is 16 not 10. And to this I'll add another speculative answer, similar to others that have been advanced, but I'm not sure it's ever been explicitly expressed: it means that a piecewise linear approximation in either direction can be done with good accuracy and not a huge number of segments.
- boulos 7y agoIt’s more accurate to say you probably shouldn’t be applying any operations to sRGB values directly. They’re non-linearly “compressed” and most operations assume they’re working in a linear space. Of course, if you want, you can figure out the equivalent “chain rule” of your operation, but realistically sRGB also mostly exists to compress colors into 8-bits per channel which doesn’t allow for great manipulation. Fun fact: this is why LRBni had a “load 8-bit as sRGB and upconvert to linear floating point”.
- contravariant 7y agoTo make matters more interesting the actual gamma curve you should be using should be the one corresponding the the display you use to view the image. Very frequently this isn't sRGB or anything close to it (pure power gamma curves are relatively common, if you're lucky the gamma is somewhere close to 2.4). It is in fact not even rare to encode an image with a gamma curve that's intentionally different from the display that's supposed to be used to view it, in order to, for example, prevent crushing black details or to avoid numerical problems (both reasons for the linear component in sRGB).