User's Guide to GIMP 2.9/2.10 Color Management and Color Mixing
GIMP 2.9/2.10 is a radical departure from GIMP 2.8, offering:
- New precision options for high bit depth, radiometrically correct editing.
- New color management options.
- New and corrected color space decompositions, blend modes, and conversions to black and white.
- Floating point precision with unclamped editing.
Written November 2015. Updated August 2017. Please note that much of the information on this page is not valid for the recently released GIMP 2.9.6. Hopefully eventually I'll find the time to update this tutorial, but it won't be any time soon.
Part 1: New high bit depth precision options, New color management options, New algorithms
Introduction: high bit depth GIMP 2.9/2.10
Purpose of this guide
This user's guide introduces you to some of high bit depth GIMP's new editing capabilities that are made possible by GEGL's high bit depth processing. The guide also points out a few "gotchas" that you should be aware of. Please keep in mind that GIMP 2.9 really is a development branch, so many things don't yet work exactly like they will work when GIMP 2.10 is released.
Useful links: the official GIMP website, builds for Windows and MAC, building GIMP on Linux
- GIMP website
- GIMP IRC and mailing list information
- Partha's GIMP 2.9 builds for Windows and MAC, including a portable Windows build of my patched GIMP plus information on compiling GIMP on Windows.
- Precompiled versions of high bit depth GIMP are more or less widely available for the various Linux operating systems. If you run Linux and you'd like to compile high bit depth GIMP yourself, Building GIMP for artists and photographers has step-by-step instructions.
High bit depth GIMP is a work in progress. The primary goal for the GIMP 2.10 release is full "Geglification" of the GIMP code base.
Editing in sRGB vs editing in other color spaces
For best results when using GIMP 2.9/2.10, only edit sRGB images.
GIMP 2.8 has hard-coded sRGB parameters that make many editing operations produce wrong results for images that are in RGB working spaces other than sRGB. GIMP 2.9 does have — and almost certainly GIMP 2.10 will have — these same hard-coded sRGB parameters.
Full support for editing images in other RGB working spaces likely won't happen at least until GIMP 3.0. However, the next big change for GIMP will be the change-over from GTK+2 to GTK+3 (or GTK+4?), which is a pretty critical step as GTK+2 is on the verge of being retired. GIMP development is a volunteer effort, porting GIMP over to GEGL has required an enormous amount of work, and porting from GTK+2 to GTK+3 isn't exactly a trivial task. More GIMP developers would help a lot, so if you have any coding skills, please consider volunteering.
If you really do want to edit in color spaces other than sRGB, my patched version of GIMP 2.9 ("GIMP-CCE") allows you to edit in any well-behaved RGB working space. However, please be aware that default GIMP has quite a lot of functionality that I've removed from GIMP-CCE.
New high bit depth precision options
Menu for choosing the image precision
As shown by the screenshot below, high bit depth GIMP offers five different image precisions:
- Three integer precisions: 8-bit integer, 16-bit integer, and 32-bit integer.
- Two floating point precisions: 16-bit floating point and 32-bit floating point.
Which precision should you choose for editing?
If you have a fast computer with a lot of RAM, I recommend that you always promote your images to 32-bit floating point before you begin editing. Here's why:
- Regardless of which precision you choose, all babl/GEGL/GIMP internal processing is done at 32-bit floating point. Read that sentence three times.
- There seems to be a small speed penalty for not using 32-bit floating point precision.
- The Precision menu options dictate how much memory is used to store in RAM the results of internal calculations:
- Choosing 32-bit floating point precision allows you to take full advantage of GEGL's 32-bit floating point processing.
- If you are working on a lower-RAM machine, performance will benefit from using 16-bit floating point or integer precision, but of course the price is a loss in precision as new editing operations use the results of previous edits as stored in memory.
- On very low RAM systems, performance will benefit even more from using 8-bit integer precision. But if you use 8-bit integer precsion, you are throwing away most of the advantages of working with a high bit depth image editor.
- 64-bit precision is made available mostly to accomodate importing and exporting very high bit precision images for scientific editing. You don't gain any computational precision from using 64-bit precision for actual editing. If you choose 64-bit precision for editing, all you are really doing is wasting system RAM resources.
As discussed in Part 2 of this article, "Using high bit depth GIMP's floating point precision for unclamped editing" (and depending on your editing style and goals), instead of 32-bit floating point precision, sometimes you might prefer using 16-bit or 32-bit integer precision. But making full use of all of high bit depth GIMP's new editing capabilities does require using floating point precision.
Using the image precision options when exporting an image to disk
The precision menu options have another extremely important use beside dictating the precision with which the results of editing operations are held in RAM. When you export the image to disk, the precision options allow you to change the bit depth of the exported image.
For example, some image editors can't read floating point tiffs. So if you want to export an image as a tiff file that will be opened in another image editor that can only read 8-bit and 16-bit integer tiffs, and your GIMP XCF layer stack is currently using 32-bit floting point precision, you might want to change the XCF layer stack precision to 16-bit integer before exporting the tiff.
After exporting the image, don't forget to hit "UNDO" ("Edit/Undo . . . ", or else just use the CNTL-Z keyboard shortcut) to get back to 32-bit floating point precision (or whatever other precision you were using).
New color management options
High bit depth GIMP automatically detects camera DCF information
For reasons only the camera manufacturers know, instead of embedding a proper ICC profile in camera-saved jpegs, usually they embed "DCF" and "maker note" information. Whenever a camera manufacturer offers the option to embed a color space that isn't officially supported by the DCF/Exif standards, each manufacturer feels free to improvise with new tags.
High bit depth GIMP does detect and assign the correct color space for most camera-saved jpegs. Like all editing software, GIMP has to play "catch up" with new tags for new color spaces offered by new camera models.
Tell your camera manufacturer that you want proper ICC profiles embedded in your camera-saved jpegs.
Black point compensation
Unlike GIMP 2.8, GIMP 2.9 does offer black point compensation as an explicit option, and it's enabled by default.
Even though black point compensation is checked by default in high bit depth GIMP, whether you should use black point compensation partly depends on the color management settings provided by the other imaging software that you routinely use. For example, Firefox doesn't provide for black point compensation. So if one of your goals is to make sure that images look the same as displayed in various softwares, you need to make sure all the relevant color management settings match.
What is black point compensation? LCD monitors can't display "zero light". There's always some minimum amount of light coming from the screen. Fill your screen with a solid black image, turn out all the lights and close the doors and curtains, and you'll see what I mean.
Black point compensation compensates for the fact that RGB working spaces like sRGB allow you to produce colors (for example solid black, R=G=B=0) that are darker than your monitor can actually display. GIMP uses the LCMS2 black point compensation algorithm, which very sensibly scales the image tonality so that "solid black" in the image file maps to "darkest dark" in the monitor profile's color gamut.
However, depending on your monitor profile, using or not using black point compensation might not make any difference at all. The only time black point compensation makes a difference is if the Monitor profile you choose in "Preferences/Color management" actually does have a "higher than zero" black point.
New and updated algorithms for converting to Luminance, LAB, and LCH
Converting sRGB images from Color to Black and White using Luma and Luminance
Under "Colors/Desaturate/Desaturate" (not a typo — "Desaturate" is one of the items under the "Colors/Desaturate" menu), GIMP 2.9 offers five options for converting an sRGB image to black and white:
- Luminance is equal to (the Red channel times 0.213) plus (the Green channel times 0.715) plus (the Blue channel times 0.072), done on RGB encoded linearly.
- Luma (almost equivalent to the GIMP 2.8 "Luminosity" option) is equal to (the Red channel times 0.213) plus (the Green channel times 0.715) plus (the Blue channel times 0.072), but done on RGB encoded using the sRGB TRC.
High bit depth GIMP's "Luma" option uses slightly different multipliers for calculating Luma: (the Red channel times 0.222) plus (the Green channel times 0.717) plus (the Blue channel times 0.061). The GIMP 2.8 multipliers were wrong and the GIMP 2.9 multipliers are correct.
- Lightness (HSL) adds the lowest and highest RGB channel values and divides the result by two.
- Average (HSI Intensity) sums all three RGB channel values and divides the result by three.
- Value (HSV) takes the maximum of R, G, and B.
"Luminance" is short for relative luminance. Luminance is calculated using the same channel multipliers that are used to calculate Luma. The mathematical difference between calculating Luma and Luminance is as follows:
- Luma is calculated using RGB channel values that are encoded using the sRGB TRC.
- Luminance is calculated using linearized RGB channel values, producing a radiometrically correct and physically meaningful conversion from color to black and white.
Of the various options in the "Colors/Desaturate" menu, "Luminance" is the only physically meaningful way to convert from color to black and white. The Red, Blue, and Green Luminance/Luma channel multipliers are specific to the sRGB color space. These channel multipliers are actually the "Y" components of the sRGB ICC profile's XYZ primaries. As you might expect, different RGB working spaces have different "Y" values, and so the high bit depth GIMP 2.9 conversions to Luma and Luminance only produce correct results for sRGB images.
Decomposing from sRGB to LAB
Decomposing to LAB does use hard-coded sRGB parameters and so will produce wrong results in other RGB working spaces.
In GIMP 2.8, decomposing an sRGB image to LAB produced flatly wrong results.
In high bit depth GIMP, decomposing an sRGB image to LAB does produce mathematically correct results. But as of GIMP 2.9.4, if you use "drag and drop" to pull the decomposed grayscale layers over to your sRGB layer stack, there is still a small error in the resulting RGB layer. Figure 3 below illustrates the problem:
Assuming you start with an image in the regular sRGB color space, then:
- In GIMP 2.9, decomposing a layer to LAB in GIMP 2.9 produces mathematically correct results.
However, dragging the resulting grayscale channels back to the RGB XCF color stack results in a slightly wrong result. This is because the dropped grayscale layer(s), which don't have an embedded ICC profile, are assumed to be encoded using the sRGB companding curve (Tone Reproduction Curve, "TRC"), when really they are encoded using the LAB companding curve. This is a color management problem that can be solved by enabling GIMP to do grayscale color management (all that's needed is a little developer time — did I mention that GIMP really does need more developers?).
As an incredibly important aside, a mathematically correct conversion from sRGB to LAB Lightness and back to sRGB produces exactly the same thing as using GIMP 2.9's "Colors/Desaturate/Luminance" option to change an sRGB image from color to black and white.
- In GIMP 2.8, decomposing a layer to LAB produces wildly mathematically incorrect results, and dragging the resulting channel(s) back to the RGB XCF color stack also produces wildly mathematically incorrect results. So older GIMP tutorials on using the LAB Lightness channel to convert an image to black and white won't produce anywhere near the same results when using GIMP 2.9/GIMP 2.10.
If you'd like to know more about "LAB Lightness to black and white", the following two-part article untangles the massive amounts of confusion regarding converting an RGB image to black and white using the LAB Lightness channel:
- LAB Lightness to black and white using GIMP 2.8.
- LAB Lightness to black and white using GIMP 2.9 and PhotoShop — the typical PhotoShop tutorial on using the LAB Lightness channel to convert to black and white does produce mathematically incorrect results.
LCH: the actually useable replacement for the entirely inadequate color space known as "HSV"
HSV ("Hue/Saturation/Value") is a sad little color space designed for fast processing on slow computers, way back in the stone age of digital processing. HSV is OK for picking colors from a color wheel. But it's really wretched for just about any other editing application, because despite the fact that "HSV" stands for "Hue/Saturation/Value", you actually can't adjust color and tonality separately in the HSV color space.
"LCH" stands for "Lightness, Chroma, Hue". LCH is mathematically derived from the CIELAB reference color space, which in turn is a perceptually uniform transform of the CIEXYZ reference color space. Unlike HSV, LCH is a physically meaningful color space that allows you to edit separately for color and tonality.
Very roughly speaking:
- LCH Lightness corresponds to HSV Value.
- LCH Chroma corresponds to HSV Saturation.
- LCH Hue corresponds to HSV Hue (the names are the same, but the two blend modes are based on very different mathematics).
- LCH Color is a combination of LCH Chroma and Hue, and corresponds to HSV Color, which is a combination of HSV Hue and Saturation (again, the names are the same, but the two blend modes are based on very different mathematics).
LCH blend modes and painting are a game-changing addition to high bit depth GIMP editing capabilities. If you'd like to see examples of what you can do with LCH, that you can't even come close to doing with HSV, I've written a couple of tutorials on using GIMP's LCH color space capabilities:
- A tutorial on GIMP's very awesome LCH Blend Modes, which shows how to use GIMP's new LCH blend modes to repair a badly damaged image, and then to colorize a black and white rendering of the image.
- Autumn colors: An Introduction to High Bit Depth GIMP's New Editing Capabilities, which shows how to use GIMP's new LCH blend modes to edit separately for color and tonality.
In GIMP 2.9, LCH calculations do use hard-coded sRGB paramters, and so will produce wrong results in other RGB working spaces.
GIMP 2.9 also provides an LCH color picker, and an LCH "Hue-Chroma" tool, which can be used in place of the HSV color picker and "Hue-Saturation" tool. [NEEDS A SCREENSHOT]
Part 2: Radiometrically correct editing, floating point precision with unbounded ICC profile conversions and unclamped editing
Radiometrically correct editing
Linearized sRGB channel values and radiometrically correct editing
One goal for GIMP 2.10 is to make it easy for users to produce radiometrically correct editing results. "Radiometrically correct editing" reflects the way light and color combine out there in the real world, and so requires that the relevant editing operations be done on linearized RGB.
Like many commonly used RGB working spaces, the sRGB color space is encoded using perceptually uniform RGB. Unfortunately colors simply don't blend properly in perceptually uniform color spaces. So when you open an sRGB image using GIMP 2.9 and start to edit, in order to produce radiometrically correct results, many GIMP 2.9 editing operations will silently linearize the RGB channel information before the editing operation is actually done.
GIMP 2.9 editing operations that automatically linearize the RGB channel values include scaling the image, Gaussian blur, UnSharp Mask, Channel Mixer, Auto Stretch Contrast, decomposing to LAB and LCH, all of the LCH blend modes, and quite a few other editing operations.
GIMP 2.9 editing operations that ought to, but don't yet, linearize the RGB channels include the all-important Curves and Levels operations. For Levels and Curves, to operate on linearized RGB, change the precision to "Linear light" and use the Gamma hack. However, the displayed histogram will be misleading.
The GIMP 2.9 editing operations that automatically linearize the RGB channel values do this regardless of whether you choose "Perceptual gamma (sRGB)" or "Linear light" precision. The only thing that changes when you switch between the "Perceptual gamma (sRGB)" and "Linear light" precisions is how colors blend when painting and when blending different layers together.
(Well, what the Gamma hack actually does changes when you switch between the "Perceptual gamma (sRGB)" and "Linear light" precisions, but the way it changes varies from one operation to the next, which is why I advise to not use the Gamma hack unless you know exactly what you are doing.)
Using the "Linear light" option in the "Image/Precision" menu
In GIMP 2.9, when using the Normal, Multiply, Divide, Addition, and Subtract painting and Layer blending:
- For radiometrically correct Layer blending and painting, use the "Image/Precision" menu to select the "Linear light" precision option.
- When "Perceptual gamma (sRGB)" is selected, layers and colors will blend and paint like they blend in GIMP 2.8, which is to say there will be "gamma" artifacts.
The LCH painting and Layer blend modes will always blend using Linear light precision, regardless of what you choose in the "Image/Precision" menu.
What about all the other Layer and painting blend modes? The concept of "radiometrically correct" doesn't really apply to those other blend modes, so choosing between "Perceptual gamma (sRGB)" and "Linear light" depends entirely on what you, the artist or photographer, actually want to accomplish. Switching back and forth is time-consuming so I tend to stay at "Linear light" precision all the time, unless I really, really, really want a blend mode to operate on perceptually uniform RGB.
A note on interoperability between Krita and GIMP
Many digital artists and photographers are switching to linear gamma image editing. Let's say you use Krita for digital painting in a true linear gamma sRGB profile, specifically the "sRGB-elle-V4-g10.icc" profile that is supplied with recent Krita installations, and you want to export your image from Krita and open it with GIMP 2.9.
Upon opening the image, GIMP will automatically detect that the image is in a linear gamma color space, and will offer you the option to keep the embedded profile or convert to the GIMP built-in sRGB profile. Either way, GIMP will automatically mark the image as using "Linear light" precision.
For interoperability between Krita and GIMP, when editing a linear gamma sRGB image that was exported to disk by Krita:
- Upon importing the Krita-exported linear gamma sRGB image into GIMP, elect to keep the embedded "sRGB-elle-V4-g10.icc" profile.
- Keep the precision at "Linear light".
- Then assign the GIMP built-in Linear RGB profile ("Image/Color management/Assign"). The GIMP built-in Linear RGB profile is functionally exactly the same as Krita's supplied "sRGB-elle-V4-g10.icc" profile (as are the GIMP built-in sRGB profile and Krita's "sRGB-elle-V4-srgbtrc.icc" profile).
Once you've assigned the GIMP built-in Linear RGB profile to the imported linear gamma sRGB Krita image, then feel free to change the precision back and forth between "Linear light" and "Perceptual gamma (sRGB)", as suits your editing goal.
When you are finished editing the image that was imported from Krita to GIMP:
- Convert the image to one of the "Perceptual gamma (sRGB) precisions ("Image/Precision").
- Convert the image to the Krita-supplied "sRGB-elle-V4-g10.icc" profile ("Image/Color management/Convert").
- Export the image to disk and import it into Krita.
If your Krita image is in a color space other than sRGB, I would suggest that you simply not try to edit non-sRGB images in GIMP 2.9 because many GIMP 2.9 editing operations do depend on hard-coded sRGB color space parameters.
High bit depth GIMP's unbounded floating point ICC profile conversions (handle with care!)
Compared to most other RGB color spaces, the sRGB color space gamut is very small. When shooting raw, it's incredibly easy to capture colors that exceed the sRGB color space.
Every time you convert saturated colors from larger gamut RGB working spaces to GIMP's built-in sRGB working space using floating point precision, you run the risk of producing out of gamut RGB channel values. Rather than just explaining how this works, it's better if you experiment and see for yourself:
- Download this 16-bit integer ProPhotoRGB png, "saturated-colors.png".
- Open "saturated-colors.png" with GIMP 2.9. GIMP will report the color space profile as "LargeRGB-elle-V4-g18.icc" — this profile is functionally equivalent to ProPhotoRGB.
- Immediately change the precision to 32-bit floating point precision ("Image/Precision/32-bit floating point) and check the "Perceptual gamma (sRGB)" option.
- Using the Color Picker Tool, make sure the Color Picker is set to "Use info Window" in the Tools dialog. Then eye-dropper the color squares, and make sure to set one of the columns in the Color Picker info Window to "Pixel". The red square will eye-dropper as (1.000000, 0.000000, 0.000000). The cyan square will eyedropper as (0.000000, 1.000000, 1.000000), and so on. All the channel values will be either 1.000000 or 0.000000.
- While still at 32-bit floating point precision, and still using the "Perceptual gamma (sRGB)" option, convert "saturated-colors.png" to GIMP's built-in sRGB.
- Eyedropper the color squares again. The red square will now eyedropper as approximately (1.363299, -2.956852, -0.110389), the cyan square will eyedropper as approximately (-13.365499, 1.094588, 1.003746), and so on.
- For extra credit, change the precision from 32-bit floating point "Perceptual gamma (sRGB)" to 32-bit floating point "Linear light" and eye-dropper the colors again. I will leave it to you as an exercise to figure out why the eye-droppered RGB "Pixel" values change so radically when you switch back and forth between "Perceptual gamma (sRGB)" and "Linear light".
Where did the funny RGB channel values come from? At floating point precision, GIMP uses LCMS2 to do unbounded ICC profile conversions. This allows an RGB image to be converted from the source to the destination color space without clipping otherwise out of gamut colors. So instead of clipping the RGB channels values to the boundaries of the very small sRGB color gamut, the sRGB color gamut was effectively "unbounded".
When you do an unbounded ICC profile conversion from a larger color space to sRGB, all the otherwise out of gamut colors are encoded using at least one sRGB channel value that is less than zero. And you might get one or more channel values that are greater than 1.0. Figure 11 below gives you a visual idea of the difference between bounded and unbounded ICC profile conversions:
When converting saturated colors from larger color spaces to sRGB, not clipping would seem to be much better than clipping. Unfortunately a whole lot of RGB editing operations don't work when performed on negative RGB channel values. In particular, multiplying such colors produces meaningless results, which of course applies not just to the Multiply and Divide blend modes (division and multiplications are inverse operations), but to all editing operations that involve multiplication by a color (other than gray, which is a special case).
So here's one workaround you can use to clip the out of gamut channel values: Change the precision of "saturated-colors.png" from 32-bit floating point to 32-bit integer precision ("Image/Precision/32-bit integer"). This will clip the out of gamut channel values (integer precision always clips out of gamut RGB channel values). Depending on your monitor profile's color gamut, you might or might not see the displayed colors change appearance; on a wide-gamut monitor, the change will be obvious.
When switching to integer precision, all colors are clipped to fit within the sRGB color gamut. Switching back to floating point precision won't restore the clipped colors.
As an important aside (and contrary to a distressingly popular assumption), when doing a normal "bounded" conversion to sRGB, using "Perceptual intent" does not "keep all the colors". The regular and linear gamma sRGB working color space profiles are matrix profiles, which don't have perceptual intent tables. When you ask for perceptual intent and the destination profile is a matrix profile, what you get is relative colorimetric intent, which clips.
Using high bit depth GIMP's floating point precision for unclamped editing
I've warned you about the bad things that can happen when you try to multiply or divide colors that are encoded using negative sRGB channel values. However, out of gamut sRGB channel values can also be incredibly useful.
GIMP 2.9 does provide a number of "unclamped" editing operations from which the clipping code in the equivalent GIMP 2.8 operation has been removed. For example, at floating point precision, the Levels upper and lower sliders, Unsharp Mask, Channel Mixer and "Colors/Desaturate/Luminance" do not clip out of gamut RGB channel values (however, Curves does clip). Also the Normal, Lightness, Chroma, and Hue blend modes do not clip out of gamut channel values.
Unclamped editing opens up a whole realm of new editing possibilities. Quoting from Autumn colors: An Introduction to High Bit Depth GIMP's New Editing Capabilities:
Unclamped editing operations might sound more arcane than interesting, but especially for photographers this is a really big deal:
- Automatically clipped RGB data produces lost detail and causes hue and saturation shifts.
- Unclamped editing operations allow you, the photographer, to choose when and how to bring the colors back into gamut.
- Of interest to photographers and digital artists alike, unclamped editing sets the stage for (and already allows very rudimentary) HDR scene-referred image image editing.
Having used high bit depth GIMP for quite a while now, I can't imagine going back to editing that is constrained to only using clipped RGB channel values. The Autumn colors tutorial provides a start-to-finish editing example making full use of unclamped editing and the LCH blend modes, with a downloadable XCF file so you can follow along.
If the thought of working with unclamped RGB data is unappealing, use integer precision
If working with unclamped RGB channel data is simply not something you want to do, then use integer precision for all your image editing. At integer precision all editing operations clip. This is a function of integer encoding and so happens regardless of whether the particular editing function includes or doesn't include clipping code.
Looking to the future: GIMP 3.0 and beyond
Even though GIMP 2.10 hasn't yet been released, high bit depth GIMP is already an amazing image editor. GIMP 3.0 and beyond will bring many more changes, including the port to GTK+3 (for GIMP 3.0), full color management for any well-behaved RGB working space (maybe by 3.2?), plus extended LCH processing with HSV strictly for use with legacy files. Also users will eventually have the ability to choose "Perceptual" encodings other than the sRGB TRC.
If you would like to see GIMP 3.0 and beyond arrive sooner rather than later, GIMP is coded, documented, and maintained by volunteers, and GIMP needs more developers. If you are not a programmer, there are many other ways you can contribute to GIMP development.