Is your image editor using an internal linear gamma color space? Should it?
Rumour has it that some image editors use an internal linear gamma RGB color space to do some or all editing operations, even when the image isn't actually in a linear gamma color space. Here are some tests for checking to see whether your image editor is using linear gamma image editing "behind the scenes".
Written June 2015. Updated December 2016.
Introduction: Is your image editor using an internal linear gamma color space?
Every now and again the claim is made that one or another image editor is silently linearizing the RGB values before performing one or another editing operation. Some simple experiments will allow you to judge for yourself whether your image editor is linearizing the RGB values before performing various editing operations.
All the tests on this page compare results using regular (approximately gamma=2.2) sRGB vs linear gamma sRGB.
For a more detailed exploration of gaussian blur and Normal blend using more colors and real photographic images, see Linear Gamma vs Higher Gamma RGB Color Spaces: Gaussian Blur and Normal Blend Mode
Tests for checking to see whether/when your image editor uses an internal linear gamma color space
All the tests described below are shown on images are in the regular sRGB color space. If you want to follow along and do the tests yourself, for each test (except the last) make a new image and assign to it the regular sRGB ICC profile. If you don't have a copy of the sRGB color space (doubtful), or if you don't trust whatever sRGB profile is supplied by your image editor, use "sRGB-elle-V4-srgbtrc.icc" from my well-behaved ICC profile pack (download the zip file — the profiles are in the folder named "profiles").
Drawing a gradient
Make a new image, 600px by 200px. Pick the reddest possible sRGB red (255, 0, 0) for one end of a foreground to background RGB gradient. Pick the greenest possible sRGB green (0, 255,0) for the other end of the gradient. Draw the gradient from one end of the image to the other:
Make a solid "reddest sRGB red" layer. Paint on the layer using the "greenest sRGB green" and a soft brush:
Luminance conversion to black and white
Take the regular sRGB version of the "paint strokes" image from the previous test. Convert it to black and white using channel mixer (mono mixer), using 22% red, 72% green, and 6% blue:
Make a solid "reddest sRGB red" layer. Fill half of the layer with "greenest sRGB green" and then blur the image. In the images below, the top half of each image was given a small radius blur, and the bottom half of each image was given a much larger radius blur:
Make a solid "reddest sRGB red" layer. Put a solid "greenest sRGB green" layer above the red layer. Set the green layer to 50% opacity, using the Normal blend mode:
Make a solid "reddest sRGB red" layer. Put a solid "greenest sRGB green" layer above the red layer. Set the green layer to 50% opacity, using the Addition blend mode:
For images that will show you if your image editor is linearizing the RGB data before scaling the image to a smaller size, see Gamma error in picture scaling.
Down-sizing an image does produce better results when done on linear gamma RGB. But up-sizing an image can produce smoother results when done on perceptually uniform RGB. So the Brasseur article is a bit misleading on this point.
Should your image editor use internal linear gamma color spaces?
If you run the above tests on various image editing softwares, you'll find a wide variety of results. For example:
- PhotoShop: Some editing operations and blend modes are automatically linearized, and some are not, and some editing operations are linearized at 32-bit floating point, but not at 16-bit integer precision.
- GIMP-2.8 (an 8-bit only image editor): No editing operations or blend modes are linearized.
- GIMP-2.9 (supports high bit depth image editing): Many editing operations are linearized. But so far Levels and Curves are performed on perceptually uniform RGB, which does produce "gamma" artifacts (these types of artifacts are not demontrated by any of the above tests). Also there is no option to draw a linear gamma gradient. And results from the various blend modes depend on whether you choose "perceptual" or "linear" precision.
- Krita: Krita supports high bit depth image editing and has done so for years. However, Krita doesn't linearize any editing operations or blend modes. Instead Krita assumes the user is smart enough to choose the right RGB working space for the task at hand. Krita documentation does encourage the use of linear gamma RGB working spaces when editing at high bit depth precision.
- My patched version of high bit depth GIMP (GIMP-CCE): GIMP-CCE also does not linearize any editing operations.
Sometimes you will find an article or video that suggests that programmers of editing software are stupid for not silently linearizing editing operations and blend modes. However:
- Expecting an "8-bit only" image editor to silently linearize editing operations is just silly, amounting to trading gamma artifacts for severely posterized shadows — not a good trade-off!
- Software developers aren't nearly as dumb as videos like Computer Color is Broken would like you to believe. In fact free/libre editing software developers are pretty smart people who are well aware of the basics of RGB color mixing. To quote Krita developer Boudewijn Rempt, The author brings us his amazing discovery that linear rgb is better than non-linear, except that everyone who's been working on computer graphics has known all of that, for ages. It's textbook stuff. It's not amazing, it's just the way maths work.
- Even when editing at high bit depth precisions, not every editing operation and blend mode produces optimal results when performed on linear RGB. Compare results of posterizing an image using linear vs perceptually uniform RGB — I bet you'll prefer the latter.
- Sometimes a user might decide that the artistically correct thing to do is to deviate from radiometrically correct editing. And not all editing operations even have a "radiometrically correct" way to be done. For example, soft light blend mode has no "real world light mixing" counterpart.
- Having user control over whether an operation or blend mode is done on linear gamma or perceptually uniform RGB:
- Is a guard against having to rely on the software "always being right", as occasionally programmers do make mistakes or fail to consider all use cases.
- Gives the user an incentive and also the opportunity to experiment and learn more about how colors actually mix in the digital darkroom.
So whether your high bit depth image editor should silently linearize your image's RGB values is a complicated question with a lot of things to consider.
Personally I would like the ease of being able to instantly switch between linearized and perceptually uniform RGB, for any given editing operation and blend mode. But if my image editor doesn't give me a choice, I don't want my image editor to be automatically and silently modifying my image's RGB values. I'd far rather use an image editor that lets me choose when I want to edit perceptually uniform RGB and when I want to edit using linear gamma RGB.