What every coder should know about Gamma Correction
- Graphics
- Programming
- Developer Tools
- Web
The post is a long primer on gamma correction in digital imaging. It explains why most images are stored in a nonlinear form like sRGB, why arithmetic on those values can produce wrong-looking blends and gradients, and why converting to linear light before doing image math is often the right fix. People broadly agreed with the practical lesson that raw pixel values are not trustworthy as brightness values, especially in 8-bit pipelines. But they also said the article is dated and sloppy about what problem gamma encoding is actually solving. The biggest correction was that sRGB is not a perceptually uniform color space, and its transfer curve was not designed as a clean match for human vision. It is largely a legacy display and storage convention, so treating it as the right space for every visual operation leads to bad conclusions. That reframed the whole piece. Linear light is the right working space for operations tied to actual emitted light, like many compositing and filtering steps. It is not the universal answer for all appearance-driven tasks. For gradients, antialiasing, and some kinds of color interpolation, commenters said you often want a more perceptual space such as CIELAB or Oklab instead. Several comments also widened the scope beyond gamma alone. ICC profile handling, monitor behavior, limited-range video formats, and newer HDR or float16 pipelines all change the tradeoff. The practical consensus was simple: gamma bugs usually come from mismatched assumptions between stages of the pipeline, not from mysterious math.
If your product renders images, UI, video, or charts, treat "linear vs sRGB" as only the first decision. You need to be explicit about the color space for storage, blending, gradients, text, and export paths, or you will ship subtle but visible bugs.
- blog.johnnovak.net
- Discuss on HN