A look at darktable 2.2.0
In what is becoming its annual tradition, the darktable project released a new stable version of its image-editing system at the end of December. The new 2.2 release incorporates several new photo-correction features of note, including automatic repair of distorted perspectives and the ability to reconstruct highlights that are washed out in some color channels but not all—a type of overexposure that other editors can miss. There is a new image-warping tool that lets users edit image pixels (a first for darktable, which has historically focused on image-wide tasks like color correction). And there is at least one new tool that may prove intriguing even to users who prefer editing images in some other program: a utility for inspecting and editing color-mapping look-up tables.
Source code bundles are available for download through the project's GitHub repository and binary packages are already available for a wide variety of popular Linux distributions. Users of the 2.0 series should note, however, that opening existing darktable edit files with the 2.2 release will automatically migrate them to the newer format and render them subsequently unopenable with darktable 2.0.
New perspectives
For many users, the most useful new addition in this release will be the automatic perspective-correction tool. Imagine having an image like the one below, where straight lines appear curved due to distortion:
Using an algorithm from the Windows-only free-software program ShiftN, this new tool automatically detects off-vertical and off-horizontal lines in an image and computes the transformation needed to create a perfectly aligned, perpendicular output image.
If the algorithm does erroneously mark lines that should not be used when transforming the photo, the user can simply deselect them before generating the correction.
The user can choose whether to apply vertical correction, horizontal correction, or a combination of both, and the parameters are adjustable (although only in truly pathological cases is the algorithm likely to need much adjustment). There are also parameters available for correcting rotation and for applying a lens shift if either of those functions is necessary to align or re-center the image.
Highlights in 2.2
Washed-out highlights in an image usually occur when the light hitting the photosensor meets or exceeds the maximum value that the sensor can measure; the pixel's value then gets clipped and detail is lost. But each pixel in a color image sensor consists of separate red, green, and blue monochrome sensors (at least, for the most common camera types), and it is possible that only one or two of those subpixels has been maxed out. Darktable deals with these cases in a different manner than the case where all three colors are washed out: it reconstructs luminance information from the non-overexposed color channels. That produces grayscale pixels that have at least some texture (as opposed to being flat fields of plain white). So, while the clipped region is still nearly white, it can still exhibit some gradation and reveal some shapes.
This option is the "reconstruct in LCh" mode of darktable's existing highlight-reconstruction tool but, in prior releases, it simply did not work—despite how nice it sounds in theory. In the 2.2 release, "reconstruct in LCh" has been rewritten from scratch and now works as advertised. Moreover, darktable now offers an on-canvas indication of which subpixels are clipped and which are not: a checkerboard pattern utilizing red, green, and blue checks in the washed-out image region.
This clipping information can be computed from the original raw camera file, even before standard transformations like white balancing are performed. When this indicator is activated, it enables the user to spot instances where it is possible to recover more image data from a washed-out image than would otherwise be possible. In the case where all subpixels are clipped, no detail can be recovered with the "reconstruct in LCh" mode. As was mentioned in our look at the 2.0 release, darktable's highlight-reconstruction tool also offers a way to fill in these entirely washed-out areas by copying colors from the surrounding pixels, but that option is something of a last resort. The now-working "reconstruct in LCh" mode is likely preferable.
Strictly speaking, of course, one should not take overexposed images in the first place (perhaps, instead, bracketing exposures if one is unsure of how to get the best shot), but "only take perfect pictures" is hardly practical advice. And overexposed pixels can result from image processing itself; any time the user applies exposure compensation in darktable or some other program, clipped highlights can be among the side effects.
Speaking of bracketing exposures, darktable 2.2 adds another tool designed to help with difficult-to-capture situations. In scenarios where the dynamic range of a scene is too wide to be captured in a single shot, the photographer can shoot multiple exposures (e.g., one to capture the highlights and one for the shadows). Those exposures can then be combined via darktable's new "exposure fusion" module. In essence, the two frames (or however many were taken) are stacked together, then the lighter portions of the darker image and the darker portions of the lighter image are blended to produce one image that looks more-or-less correct everywhere.
This is same the technique found in the Enfuse utility, and similar approaches are available in other "high dynamic range" (HDR) image-processing tools like Luminance HDR (both of which LWN looked at briefly in 2012). Sadly, neither Enfuse nor Luminance HDR has made much progress toward a new stable release since 2012. So the addition of the exposure fusion module in darktable is a welcome sight. Perhaps that is the better option in the long run, since using a single-purpose application like Enfuse makes for a more complicated workflow than most users want. But all of the usual caveats about HDR images apply to darktable's new module: it is easy to overdo the blending process, creating distracting artifacts like halos or producing weird, washed-out looking results. Proceed with caution.
Distort all the things
A key distinction between photo-manipulation programs like darktable and RawTherapee and raster image editors like GIMP is that the former are intentionally restricted to "post-production" image-tuning operations. That means they focus on making adjustments to the hue, saturation, and lightness of the pixels in the image as a whole (or in large portions of the whole), as opposed to painting or drawing with tools onto a canvas. Various names are trotted out for such applications: "raw photo editor" was one of the first; "photo workflow application" is more recent, although neither really seems to communicate the idea unambiguously.
On the plus side, "workflow" adjustments can easily be implemented as non-destructive transformations, and the operations used on any particular image can be saved in a compact file format. The downside is that, in real life, one eventually runs into some situations where on-canvas editing is required.
The darktable 2.2 release adds what could reasonably be considered the application's first on-canvas tool for image manipulation (with possible exceptions going to special cases like flipping and rotating). It is called Liquify and it lets the user deform the image by pinching, stretching, and warping pixels.
The name "Liquify" is seemingly borrowed from Adobe Photoshop, though similar functionality can also be found in GIMP's IWarp filter.
Darktable lets the user add a single-point warp node that will stretch, compress, and twist the surrounding pixels within a user-defined radius, or the user can connect several such nodes along a vector path and warp a larger portion of the image. To be sure, the Liquify tool will not suffice for every possible operation, but it is an important first step. If bending or reshaping one portion of a photograph is all that is needed, doing so in darktable is more convenient that exporting the image to a separate raster file and opening it with GIMP.
Darktable is looking up
Whereas the Liquify tool manipulates pixel positions in space, the vast
majority of darktable's other functions manipulate pixel colors in some
specified fashion: adjusting the white point, brightening the dark
regions, shifting certain hues, and so on. The final new tool in the
2.2 release is another color-adjustment feature, but it is a feature
that can best be thought of as a generic color-mapping function. The
color look-up table (CLUT) tool supports remapping all of the colors
in the image based on some predefined set of transformations.
Remappings of this type are how "film emulation" features work: when someone takes the time to measure the output of known sample images exposed on Kodachrome 64, Fuji Velvia 50, or some other film stock, they can produce a mapping that transforms a generic RGB image into something that looks more vintage. Photographer and GIMP team member Pat David, for example, has created several hundred open-source film-emulation CLUTs that are already usable in GIMP's G'MIC plugin and in RawTherapee. But there are other important CLUTs found in the wild, such as those that digital cameras apply when converting a raw image into a JPEG to be saved on the memory card. Being able to apply the same CLUT to a raw image in darktable would ensure that its output matches the camera's JPEG exactly.
This is indeed what the new tool in darktable can do—at least, if the CLUT of interest is available. At present, the process of creating those CLUTs is only beginning, with a handful of mappings available.
Creating a new CLUT can be a time-intensive task. Color spaces are three-dimensional constructs—regardless of whether those dimensions are red-green-blue, hue-saturation-lightness, or something more exotic; a 3D-to-3D transformation matrix thus involves looking at a lot of sample points. But the new darktable release adds a utility called darktable-chart that can assist with the process. To match a camera's output, the user will need to purchase a calibrated IT8 target and take a reference photo, but nothing stops interested parties from fiddling around to create interesting CLUT mappings of their own. In fact, the popularity of products like Instagram suggests that it is hard to stop people from fiddling with CLUT transformations.
In the long run, CLUT support will let darktable users easily apply a large variety of color styles to their photographs, whether those styles are designed to emulate film or not. But darktable-chart may prove useful in its own right, because—as David has mentioned on his blog—the existing process for creating a CLUT is complex.
From the shadows
While the aforementioned tools are the biggest changes in the new release, there are scores of smaller improvements to be found as well. The keyboard support introduced in version 2.0 is expanded upon: arrow keys can be used to adjust sliders and controls, and modifier keys can be used to change the rates of adjustment (Shift is a 10x increase in the adjustment increment, while Control is a 0.1x reduction in the increment).
The script-friendly command-line version of darktable, darktable-cli, can now take entire directories as an input argument. Watermarks generated by darktable can now include geolocation information. And, on Linux, the application now tells the window manager when it has completed a batch operation, thus enabling the user to be notified when another application has focus.
There is also initial support for undo and redo on image-adjustment operations. That may seem like a fundamental missing piece, but one must remember that darktable's adjustments are non-destructive and most can only be applied once (e.g., you would not adjust the white balance of a photograph twice). So in most cases, undoing or changing an adjustment was a simple matter of deactivating it or resetting it to the default parameters. Still, this is a nice improvement for how most people think of editing images.
At a lower level, the project has implemented initial support for some new photosensor subpixel patterns, including CYGM and RGBE arrays. OpenCL support has also been improved, with OpenCL now used to demosaic raw images, and the first builds for ARM devices are available. Finally, the program now uses Pango for text rendering, which will enable it to be used with right-to-left languages.
Interfacing
The new feature set boasts a lot of useful additions. But, if there is any criticism to be leveled at the 2.2 release, it is that darktable still hides so much of its functionality behind user-interface choices that are invisible while simply using the program.
A good example is the substantial set of options in the perspective-correction tool that are only made available by holding down modifier keys when clicking on the "automatic fit" buttons. The existence of the modifiers is only discoverable by hovering the mouse over the buttons long enough to bring up the tooltip hints; for an application offering as many functions as darktable does, it is simply not feasible to expect users to memorize every combination of Shift, Control, and left- and right-clicking for every tool.
Other applications—for example, GIMP—find a way to present such options
in a persistent message-bar area or in a field within the toolbox itself;
there is no reason darktable cannot do the same. Instead, having to
pause and hover the mouse over every tool before you can see how to
use it is reminiscent of darktable's early days, when the filters and
controls had no text labels and users had to guess at the meaning of
cryptic icons. The application has come a long way since then; it
would seem that it still has some distance to travel.
| Index entries for this article | |
|---|---|
| GuestArticles | Willis, Nathan |

![Perspective correction, before [The perspective-correction tool in darktable]](https://static.lwn.net/images/2017/12-darktable22-perspective-1-sm.png)
![Perspective correction, during and after [The perspective-correction tool in darktable]](https://static.lwn.net/images/2017/12-darktable22-perspective-2-sm.png)
![Liquify interface [The liquify tool in darktable 2.2]](https://static.lwn.net/images/2017/12-darktable22-liquify-sm.png)