So we are looking for a tone-mapping method, a general set of rules that describe how the range is stomped together. Some kind of filter or histogram compressor or tone curve adjustment. Everything is allowed as long as it starts out with HDR values and returns some nice LDR representation of it. It's a black box that can do whatever it wants to the image. HDR in, LDR out—that's all we ask.
These are new kinds of functions that cannot be categorized in the traditional way. Instead, they form a tool category of their own: tone-mapping operators (TMOs). There is no real naming convention for TMOs. Some names give you a hint of what's happening inside the black box, some point out a desired result, some are just named after the inventor.
Despite all their differences, there are really just two major strategies involved. This divides the huge variety into two classes: global and local operators. Global operators convert the full image in one fell swoop, whereas local TMOs do different things to different parts of the image.
Let me give you an overview of some common operators. By no means will this be a complete or in-depth description; that would be a book on its own. And in fact it is—a much more precise description of TMO algorithms can be found in the HDRI bible from Reinhard and the other founding fathers (www.hdrbook.com). I hope they forgive me when I pick some selected implementations and group them together with similar types, ignoring a lot of the technical details. My goal is just to give you a feel of what kind of unique approaches there are out there, how you can control them, and how to judge the result. To have a somewhat representative cross section of real-world scenes, I chose four test images:
Fat Cloud - 680:1 / 8.5 EVs. Dusk outdoors scene with interesting details of the clouds.
Walk of Fame - 1,500:1 / 10 EVs. Noon outdoors with badly burned-out highlights.
Coffee Shop - 7,500:1 / 13 EVs. Interior scene with warm colors and deep shadows.
Kitchen Window - 38,000:1 / 15 EVs. The hardest one, with detail inside and outside.
4.1.1. Global Operators
Global operators apply a tone curve to the whole image, squashing different parts of the histogram together. The difference is in what kind of tone curve is used here. It can simply always be the same one, it can be calculated from the histogram itself, and it can even be a different tone curve for each channel.
Simple exposure and gamma
This is what we've always looked at in Photoshop. Technically, it can hardly be called a tone-mapping operator at all. It's just a simple snapshot of our focused exposure. Highlight detail that doesn't fit in the tight bracket of LDR imagery will simply get cut off.
In many ways, this is akin to shooting a regular picture with a regular photo camera. The result looks very similar to the source image of the respective exposure. But it's not quite identical: Our virtual camera has no noise in the darks, and we can choose an arbitrary exposure in between.
A word on Photoshop: All TMOs are hidden in a dialog that comes up when you convert a 32-bit image to 8- or 16-bit.
The first option in that HDR Conversion dialog looks exactly like the first option in the 32-bit Preview Options dialog box. It even comes preloaded with whatever setting you have put in there, so it really is just baking the current display mapping down to LDR. These 2 boxes are connected: The 32-bit Preview Options show you an on-screen representation of your HDR image that looks identical to the result of the HDR Conversion. Makes perfect sense, right? Your monitor is low dynamic range by definition - so what you see is a preview of what you get after the conversion to LDR.
Note that there is still a tone curve applied. Setting the gamma slider to 1 means that in this context that the current monitor gamma will be burned in, just as we discussed in section 1.4. The slider here is just an adjustment that can make that gamma curve more or less steep. Visually it behaves like a global contrast, pushing the darks more or less up.
It's a classic conversion that is not smart at all. But it's very predictable; you get precisely what you see. When you go the hard way and massage your HDR values by hand into exactly what you want, this method is a good fixative to get an LDR snapshot. We'll do that later on.
Highlight Compression
This is the second option in Photoshop's tone-mapping palette. And it is also available for display mapping in the 32-bit Preview Options dialog box. Instead of clipping, this mode will always protect the highlights. It simply pins down the brightest spot to an LDR value of 255 and converts the rest in a logarithmic manner.
It's fully automatic; there are no options here. That's what the window says. However, you can still influence the result with some dirty tricks. Here is how it works:
In the 32-bit Preview Options dialog box, set Method to Highlight Compression.
Choose Image → Adjustments → Exposure and play with the Exposure and Gamma sliders.
When you're happy with the tonal distribution, you just pin it down by performing the HDR Conversion with the same Method.
This mode works fine when the major concern is to protect the highlights in medium dynamic scenes. The histogram is anchored on the brightest end, and the Exposure slider controls how steep the logarithmic intensity decay is. It can get a bit weird when you are painting in this preview mode because it will try to countercorrect very bright paint strokes.
So, even though this mode is listed as having no options, it is actually one of the most versatile and intuitive ones. You have the entire toolkit of Photoshop's image adjustments at your disposal, and you always have a precise full-sized preview.
Highlight Compression is not suited for very high dynamic range scenes. It naturally retains the colors underneath the highlight, which works fine for that statue, it's acceptable for the sugar sprinkler in the coffee shop, but it fails badly on the kitchen window. Here the inside and outside are just too far apart.
A key feature of this TMO is that the HDR pixels get treated with a logarithmic tone curve, which mimics the smooth highlight roll-off known from film better than a simple gamma. Picturenaut's Adaptive Logarithmic option is the same TMO, but it's wrapped in a more traditional user interface with all the relevant parameters in one dialog box. It's actually a very common operator, a true TMO classic. Other programs call it Drago, named after the inventor Frederic Drago.
Picturenaut - Photoreceptor
This one is based on the idea of emulating the receptors in a human eye instead of a film response. It uses an S-shaped tone curve that looks identical to a logarithmic curve in the middle tones. But it behaves differently on both ends. Here the slope of the curve is slightly linear, so the brightest and the darkest parts are not squashed together as much. That means we get better detail in highlights and shadows but sacrifice a bit of contrast in the middle tones.
The most prominent advantage is that it handles colors better as they get closer to white. They get more and more desaturated, which is once again an effect that happens in our eyes too. This prevents false colors, and it works quite well, as you can see in the sugar sprinkler and the kitchen window. Both have a more natural look, and highlights appear crisp and clean. But when the most interesting colors are just within that highlight end, as in the clouds example, this might be an undesirable effect.
Unlike other parametric tone mappers, Picturenaut is actually tonemapping the original image on-the-fly. So instead of just relying on the small preview, you can zoom into the full image and see your changes take effect right away. Watching the histogram squish and squash in realtime is an incredible way of learning the effects of these controls. The speed of Picturenaut is really breathtaking, and especially when you have a multicore machine, you will just love it!
Most other implementations of this TMO are simply called Reinhard, named after the inventor of the algorithm, Eric Reinhard. Popular sightings are an HDR Shop plug-in (no preview), Artizen, and a whole lot of command-line utilities. Photomatix's Tone Compressor is the same TMO with fewer controls (and probably less redundancy therein), and it's also slightly less interactive. Despite the name, FDRTool's Receptor acts more like Drago's logarithmic TMO (a.k.a. Photoshop's Highlight Compression). At least it doesn't share the color neutralizing part, which makes a real difference.
Photoshop - Equalize Histogram
This is Photoshop's third operator, and this time there are really no options. This one is 100 percent fully automatic. It doesn't apply a fixed-rule tone curve, but rather tries to iron out the histogram directly.
Imagine the histogram suddenly turning into a sand castle. Wherever there is a peak, it crumbles apart. Empty gaps will be filled up, and parts with very few values will be crunched together. That has the effect of maximizing visual contrast in the image. Why? Because peaks in the histogram represent the largest amounts of pixels, and spreading these tones out means that the majority of the pixels of the image will get a contrast boost.
It has basically the same function as the good old Auto Levels, with the exception that it doesn't leave gaps in the histogram. There is always some in-between HDR value to fill in the gap.
Well, that sounds all too fantastic, but in the real world Equalize Histogram isn't working too well. In Photoshop it tends to crunch the range on both ends together, and we end up with deeply blocked shadows and highlights that don't really stand out anymore. The overall contrast boost is incredible, but we lose a lot on the way.
A better implementation of this histogram adjustment can be found in Photosphere, behind the Auto exposure switch. Photosphere has a built-in protection for shadow details; it simply doesn't allow the tonal values to clump together on both ends.
As the name Auto suggests, it's fully automatic as well, but it also works in conjunction with the Local switch. In that case, you can zoom in and pan around and Photosphere will apply this TMO only to the current crop region.
In a nutshell
In global operators there is always a trade-off to be made between overall contrast and detail rendition, especially in highlights and shadows. Global operators might works well for scenes containing a medium dynamic range, like the upper two example images. But for the kitchen window, for example, none of the global operators work really efficiently. Photoreceptor comes close to delivering a natural look, but it still doesn't manage to get the most out of the material. This is where local operators shine.
4.1.2. Local Operators
Local TMOs are more sophisticated. Instead of applying the same tone curve to the entire image, they treat each pixel individually—well, not exactly single pixels, but groups of pixels. They can selectively pull the exposure in some areas up and in others, down. The idea is to simulate the locale adaptation mechanism of human vision.
Sounds very mysterious, doesn't it? It's actually quite simple. They generate in the background a mask that is basically just a blurred version of the luminance channel. It looks something like in the examples above.
Once they have a good mask, they can, for example, separate the window from the rest. Then they can pull down the exposure in that area without having to sacrifice contrast anywhere else. They could even make the window view darker than the interior. Also, they could treat each level of grey as a separate zone and boost the contrast locally for each zone. Obviously, the success of a local tone mapper is highly dependent upon the quality of this mask. If the blur crosses the window frame, there is no more separation happening. Then you get halos. If that blur is not wide enough, it will treat each pixel separately and all the details will be mushed together.
How this mask is made, and what is to be done within these zones, is what sets local tone mappers apart from each other. Each one has a different set of controls too. If there are sliders labeled Radius or Smoothing, this refers to the amount of blur and you know that you have a local TMO in front of you.
Photoshop: Local Adaptation
We start off with Photoshop's flagship tone mapper. Option number four: Local Adaptation.
❶ At first glance it doesn't look like a local operator at all. But it is one—we have a radius slider that controls the amount of mask blur and a threshold that defines where to blur and where to keep sharp edges. Even at default settings it does a nice job in separating the window from the interior. The mask underneath probably looks more like the leftmost mask example.
The big curve view is normally collapsed—make sure to unfold it by clicking the triangle icon. This is where the party starts. We have a true HDR histogram in the background; the red ticks on the bottom indicate one EV each. So we can now shape a custom tone curve and precisely define how the HDR tonal values are mapped to LDR. One hint: When it all gets too hairy, you can reset everything by holding the Alt key and clicking the Cancel button.
❷ The first step is to get to know the histogram. When you hover over the image, your mouse pointer turns into the eyedropper icon. Drag it around holding the mouse button and watch the little indicator circle dance up and down that curve. The horizontal position of that indicator points you to the histogram position that represents this spot of the image. Try to memorize what all the peaks are. Here the last steep peak is the sky, and the alps in the center appear to be the walls. Also, figure out where smooth gradients stretch out, and locate the spots where you want to add some contrast. In this case, I like the wall texture so much that I would like to bring that out a bit more.
❸ The next step is usually to bring in the outer limits of the curve. Bottom left is the black point; top right is the white point. In this case I don't need to do that because they perfectly fit the histogram already. What appears to be a gap behind the sky peak is actually held open by the Hollywood sign—for sure I wouldn't want to clip that off.
ɹ OK, now we're ready to rock that curve! Personally, I prefer to work in an inside-out workflow. So I start by setting two points on the curve, around the highlight on the wall, and pull them apart vertically. That makes the slope between them steeper, which is causing a contrast boost there.
It also turns the curve into a wild S shape, pushing the sky up the scale. Quite sensitive, such a curve interface—you always get this whiplash effect when they overshoot.
➀ But this time we have a rescue button. You can mark the selected point as a corner with the little check box underneath. This is a pretty cool way to define several independent zones of high and low contrast.
➁ Let's recap this on the window: Sample first and watch the circle dance. Then go in and tweak the curve. Here I shape a little S curve specifically for that window zone to boost a bit of contrast. It's very subtle, but it shows on the trees and the little architectural checkerboard pattern. To keep the sky from going too far into the baby blue, the last curve point gets cornered off. Pretty crazy curve I am ending up with, isn't it? These corner points are especially unusual; in a regular curve adjustment they would cause some bad color banding. Not so much here.
We have more precision values to scoop from, and even more importantly, this curve adjustment is getting smoothed out by the radius and the threshold value. The invisible blurry-effect mask, remember? It effectively divides the pixels into zones. And the average luminance of each zone is what the curve is getting applied to. Let's have a closer look at how that works.
❼ When the radius is pulled down to 1, each zone is only one pixel plus its direct neighbors. So that curve always affects 5 pixels at a time. That looks just like a regular sharpening filter. If the radius is too large, all pixels outside the window fall into the same zone. They are practically treated as if they all had identical luminance and the window view flattens out entirely. The optimum radius is somewhere around the size of the trees, which is the smallest patch of local detail I want to keep together in a zone.
➃ Threshold has an even more dramatic effect. It defines how far the luminance of two pixels can be apart and be still considered as within the same zone. If it's set too low, each and every pixel is a zone for itself. Then our operator really acts like a global TMO, applying the curve equally to each pixel. But if the threshold is set too high, then even pixels with extreme luminance differences get identical treatment. It's like our effects mask would bleed over sharp edges, and we get the dreaded halo artifacts. The optimum setting here is just below the first visible halo.
As you see, there is a lot of control behind this supposedly simple tone mapper. If you master the curves, the force will be with you. You'll be able to reshape the tonal range just the way you want it. Yes, it can get tedious at times, especially when curves are not your favorite kind of interface. Specifically annoying is the fact that this curve window is locked in size—so the granularity of this control is limited to your pixel-perfect aiming skills. Hardcore gamers clearly have the advantage here.
You might have noticed by now that these example images cannot be compared 1:1 between tone mappers. This is meant more to show you samples so you can inspect the specific aspects mentioned in the text. With this set of examples, it's an invitation to study the curves to see how they affect the image.
For the tech-savvy readers, it should be mentioned that the underlying technology is called bilateral filtering, which directly refers to the way pixels are grouped into zones. Strictly speaking, this is even considered a TMO class of its own, but in a chat among friends, it's safe to call it a local operator.
Photomatix - Details Enhancer
This TMO is the shooting star that made Photomatix famous. The photographic community seems to love it. It seems to extract more local contrast with less effort than Photoshop. All controls are clearly labeled sliders and further described in rollover quick tips—a prime example of great usability.
The capabilities of this operator are truly remarkable. It takes a fair bit of experimentation, but its worth the effort to get familiar with it. How to tame Photomatix will be explained in detail by expert photographer Dieter Bethke at the end of this chapter. Right now I'll just give you a quick teaser.
The left column is tonemapped with default settings, straight in and out. On the right side all settings are pulled to the extreme, just to illustrate how much local contrast it can possibly grab. By extreme settings I mean full strength, full micro-contrast, and no smoothing at all. Couldn't resist adjusting to the white and black point, though.
In Photomatix you set all parameters on a smaller-scale preview image. It offers a 100% preview zoom, and in that case it applies the operator only to the region shown in the preview. But you should be aware that the same crop in the final result can look entirely different. This is just the nature of the beast. Local operators have to analyze the whole image at the pixel level. Think back to the blurred effects mask. And imagine the difference between crop-blur and blur-crop.
FDRTools - Compressor
Despite the different interface style, FDR Compressor is very similar to Photomatix Details Enhancer. Detailed rollover tips help you understand the controls, which are trimmed down to the minimum. Setting the white and black point is a bit more intuitive but less precise. Instead of a numerical input field, it has sliders directly underneath the histogram.
Just as in Photomatix, all settings are made just on a small-scale preview. But FDRTools goes even further. There is no OK or Apply button or anything similar. You have to click Save, and then it starts a script that will do the actual work. It will load the image again and apply the tone mapping. Sounds like a strange way to work. Apparently it's made for merging to HDR and tonemapping the images right away while working on preview images all the time in between, which sounds even more strange. But on the flip side, FDRTools can run that process over and over again and automatically change the parameters on each run. It's called compression bracketing or contrast bracketing—pretty helpful for the indecisive.
Artizen HDR - Lock06/Fattal
Artizen HDR deserves to be mentioned as the program with the largest selection of tone mappers. On top of that, it is a full-featured paint package. All global TMOs can be used as display mappers, too, which is precisely where HDRI will be heading in the future.
Unfortunately, the present is not as great as the promise. In this merciless comparison test, this one gave me the most headaches. There was no way to leave the parameters on default settings. While all other programs would always return some kind of acceptable result, I spent most of the time in Artizen fighting nasty tone-mapping artifacts like halos and oversaturation. For example, all Fattal examples were made with a saturation setting of zero—the low end of the scale. You would think that would return a fully desaturated image, but apparently that is not the case.
So please be aware that these results might just be caused by a particularly buggy version or just plain user error on my part. Maybe the bug was really in front of the keyboard, and you're having more luck taming Artizen than I.
4.1.3. Human Operator
If you don't trust any of these tools, why don't you take tone mapping into your own hands? You can simply re-expose selective parts of the image yourself and literally massage the range piece by piece until it fits the tonal range of the display. This approach is not new at all; in fact, it is the oldest trick in the book. It's exactly like dodging and burning during the analog development process. Not the digital burn-and-dodge brushes that you used to have in LDR; those were just fakes. They were just pushing around values that had already been developed, but in this technique, you can really re-expose spot by spot.
In the most basic form, you would just make a selection in Photoshop and grab the hard exposure control from the Image → Adjustment menu.
There's no magic here. Just manual labor and precise control over the result.
Of course, you are better off using adjustment layers so you can tweak the selection afterward. Figure ❶ shows how this technique really works::
❶ Start off with a rough selection, i.e., the window view.
Create an exposure adjustment layer with the widget on the bottom of the Layers palette.
Tune it to taste. Make good use of the Gamma Correction slider to control visual contrast.
Take a soft brush with a very low flow setting and paint in that exposure to other, similar parts.
Then it's really up to your skill with the brush how well the mask fits. The Smudge and the Blur tools are great helpers here, but your best friend will be a Wacom tablet.
❷ We can stack another adjustment layer on top of that for bringing up the shadows. When you use a very large soft brush and gently touch up whole shadow areas, it blends in as all natural. But you'll see the details emerge from the shadows, exactly where and how you want them. It's totally your call.
Once you like what you see, you'd just bake it down. Merge all layers and convert to 8- or 16-bit with the simplest option possible. At this point you really just fix what you see by burning in the current display exposure and gamma. That's it.
The whole technique is very similar to exposure blending, where you just manually merge the original photographs by masking out the best parts. But it's less confusing because you don't have to take care of the layer order or blending modes or anything like that. Instead of handling separate image layers, you have only one. Can't beat the elegance in that. And remember that the noise has already been averaged out when you merged the HDRI—you are already working with nothing but the cream from the original images.