A Better Dehaze

A better Dehaze

An announcement

I’m starting a whole new series of articles!

Between the basic “Photoshop by the Numbers” stuff and the advanced “Picture Postcard Workflow” articles there is room for more Photoshop studies. Too often it happens that I have an interesting idea about some Photoshop technique, I want to write about it but it fits in neither of the two existing series. So I decided to simply remove that limitation. 

I call the series “Tutorials and Actions” and that’s what it will bring. The Tutorials part explains ideas and techniques, and the Actions part is a page of downloadable Photoshop actions. Feel free to pick up anything you like there. It contains some of the actions I already discussed (yes, related to the PPW…) and new ones will be added. The downloads are accompanied with short documentation.

This article is the kick-off. It explains what I call a “Better Dehaze” action. The idea for it occurred to me while I was working on the Clarity and Dehaze study for the PPW.

I knew that the Dehaze adjustment existed, but for me it remained too far hidden in the Lightroom panels. Now that I have looked a bit better at it, I must admit that it may work for some images. I can even imagine some people being enthousiastic about it. But I also noticed that it has a few drawbacks – and that’s where my tutorial and action come in.

The example image


Figure 1. Original image

Figure 2: Same image, quickly processed in Lightroom

Let’s have a look at an example. See figure 1 above for an original and figure 2 for the result of a quick Lightroom correction, mainly for white balance and range. This is a typical landscape photo: there is no single object that should get the focus, it’s about the total view of this lake area. The background, taking more than 80% of the image, is more important than the foreground. But it’s… hazy, isn’t it? Before we can hang this photo on the wall, we need to do something about that. Time to apply Dehaze.

First, a short refresher. Hazy areas lack contrast and color. Also, they tend to be somewhat lighter than clear image areas. The Dehaze function tries to identify hazy areas by some clever algorithm, and then makes them darker, more contrasty and more saturated. It’s as simple as that.

Below is the result of a rather aggressive application of Dehaze (+50), applied to figure 2.

Figure 3. Default application of Dehaze

So how does that look?

Well, I have mixed feelings about this result. It sort of did what it’s supposed to do. There is more color, more contrast and more darkness in the background area. The foreground trees have hardly been affected. The contrast enhancement is significant. So far, so good.

But something is wrong with the color. The adjustment brings about an ugly blue-cyan tint to the distant mountains and clouds. No doubt, this hue was already there before we applied Dehaze. A slight blue appearance of distant areas is natural and caused by scattering of light when it travels through the atmosphere. In figure 2, this blue is so vague that it looks natural. In figure 3 it has become unacceptable.

This is the motivation for my tutorial. Note that when you encounter haze that is caused more by smog than by distance, the blue cast may not be a problem. The tutorial below mainly applies to mountain landscapes. And remember, if you don’t want to go through below steps, there is a ready-made action on the new Downloadable Actions page!

The preparation phase

We need Photoshop, not Lightroom or Camera Raw. We need layers, blend modes and opacities… so no choice there.

  • Open the image in Photoshop. If there’s only one layer, duplicate it. Otherwise, create a composite layer by pressing ctrl-alt-shift-E.
  • On the new layer, Menu: Filter – Camera Raw filter. Switch to the Effects tab (symbol fx). Move the Dehaze slider a considerable amount, say +50. Save and exit the filter.

For our example image, these steps resulted in figure 3. If you find the result so far beneficial for contrast but too blue in the hazy areas, continue.

  • Call the new top layer “Dehaze luminosity”. Set its blend mode to Luminosity. It’s the contrast part of Dehaze which for now I assume to provide an improvement.
  • Copy the current layer. Call it “Dehaze color default”. Set blend mode to Color. This is the color part of the Dehaze. Or better: the saturation part, because hue is not (or hardly) affected.
  • For now, switch off visibility of the Dehaze color default layer. We will do something else with the color, but we’ll need the current layer later.

See figure 4 for an interim score for our image, plus the layer stack so far.

Figure 4. Image and layer stack for luminosity enhancement only

The Dehaze mask

Let’s pause for a moment and think about what we have now and what we need to accomplish. We blocked Dehaze’s color enhancement, so the hazy parts will be as grey as in the original. Some color is needed, warmer than what Dehaze provides. That’s not difficult, but the question is: how to limit this adjustment to the hazy areas? Clear, non-hazy areas must not get their color affected. We need some kind of mask that isolates hazy from non-hazy image areas. How to get it?

The answer: we can derive such a mask from what we just created. We can assume that the more the Dehaze luminosity layer differs from the layers below, the more effect the Dehaze action had, the more hazy the corresponding image area was. That’s the basic idea to create the mask. So let's continue our tutorial.

  • For the time being, change the Dehaze luminosity layer to blend mode Difference. What you get is a strange looking, dark orange-red representation of the image. But: the more deviation from black, the more effect the Dehaze function had. Hold on!
  • Create a new layer and Menu: Image – Apply Image. Layer: Merged, Channel: RGB. Blending Normal and Opacity 100%. Hit OK.
  • Change the layer name to Dehaze mask.
  • We are creating a mask, so we’re not interested in color. Menu: Image – Adjustments – Desaturate.
  • The result is still very dark, so Menu: Image – Auto Contrast. This makes the lightest areas of the layer white, so that we get a proper mask. You may examine the result to see if the lightest part are indeed the most hazy areas. See figure 5 below for how it looks for our example image, again accompanied with the current layer stack.

Figure 5. Dehaze mask and current layer stack

  • Open the Channels panel. From the panel menu: New Channel. Name: Dehaze channel. Check “Masked areas”.
  • Click the channel and Menu: Image – Apply Image. Layer: Dehaze mask, Channel: RGB. Blending Normal and Opacity 100%. Hit OK.
  • The channel should now look identical to the Dehaze mask layer.
  • Delete the Dehaze mask layer and set the Dehaze luminosity layer back to Luminosity.

The image and layer stack are now back to what they were in figure 4, but we have created an appropriate mask. We’re now ready for the better color. 

Finishing the tutorial

We will now create a “better color” layer set between the two Dehaze layers.

  • With the focus set to the Dehaze luminosity layer, add a Curves adjustment layer.
  • On the Curves window, switch to the Red channel and add a control point 140,180. This adds considerable red to the image.
  • Now activate the Blue channel and add a control point 170,140, to diminish the blue. It may be that the color now looks overly green-brownish or even gets an orange tint, but ignore that for now.
  • Hit OK to activate the curves adjustment. Rename the new layer to “Dehaze better color”. Set blend mode to Color.
  • Click the mask of the new layer and Menu: Apply Image. Layer: Merged, Channel: Dehaze channel. Blend mode Normal, Opacity 100%.
  • Add a Vibrance adjustment layer and set Saturation to +50, boosting saturation in a better way than the Hue/Saturation sliders do that. Blend mode Color.
  • Click the mask of the new layer and Menu: Apply Image. Layer: Merged, Channel: Dehaze channel. Blend mode Normal, Opacity 100%.
  • Rename the new layer to “Dehaze saturation”.
  • If you want, remove the Dehaze mask channel. (The action does this automatically.)

See figure 6 for the current state of affairs.

Figure 6. Image with new color and current layer stack

Almost done! The color that we now have is likely too warm. In our example, note the brownish tint in the clouds. We've gone too far with our "better color": the ideal will be somewhere between the current result and what Dehaze produces.

That’s exactly what we have the top layer for. Make it visible and move the opacity slider to recover some of the (more blue) color. The downloadable action sets this to 50% but any value between 0 and 100 may be good. A higher value means: more of the blue. A lower value: more of the orange/brown. See figure 7 for the results of setting opacity to 0, 50 and 100%.

Figure 7. Top layer (original color) applied at 0%, 50% and 100%.

Of these three, I prefer the middle version. It combines the better contrast that Dehaze provides with an agreeable color. But a different percentage may be your preference.

If you find the above too complex and just want to try and use the action, go to the new Actions page and download it from there, together with a concise manual.

Gerald Bakker, 24 August 2017

Tutorials and Actions