Home ›› Restoration Tutorials ›› Fixing a hazy landscape using Photoshop or Paintshop Pro
Fixing a hazy landscape using Photoshop or Paintshop Pro

Last update:  12-31-1969

Submitted by bart_hickman

Ever take a photo of a wonderful view of a distant subject that's terribly washed out due to haze? Never fear, this tutorial is here to rescue you! This tutorial is written in Photoshop CS2, but it'll work in any version that has a background eraser and surface blur features. I've also put in brief translations for Paintshop Pro (need some more work here.)

This tutorial is Copyright © bart_hickman, who has sole responsiblity for its content.
Have a question for the author? Or simply want to discuss this topic further? Click "Discuss" up at the top. If you'd like to publish a tutorial of your own, simply click on "Publish" over on the menubar.

 

Overall Recommendation

Recommended

Rating
 

8

 

Expertise     9.1
Utility     4.6
Clarity     8.1
Relevance   10

For those wanting to follow along in the tutorial, download the full sized version (2570x1713) from this link so the pixel dimensions used in the tutorial work out correctly:

2570x1713 original image

 

Here's a smaller version of what we are going to fix.  It was a typically hazy scene you see in the afternoon.  The foreground objects are clear, but the background (which is the subject) is very dim and hazy.

 

We want to enhance the subject without impacting the foreground.

 

One common trick is to use what is called a large radius sharpening.  This is where you use a unsharp mask (USM) and set the radius to something large (perhaps 30 pixels).  This enhances what is called local contrast.  This is a great technique (and we will use it in this tutorial).  However, the problem is how to confine this effect to just the sky.  If we simply perform it on the whole image, the result looks like this:

 

The background looks better, but you get a noticeable halo around the perimeter.  Masking the foreground will prevent the foreground from being impacted, but it won’t prevent the halo.  Paintshop Pro has a filter called “clarify” which is a bit fancier, but it also suffers from the halo problem.

 

This is because both filters “see” the edge of the sky and enhance it.  What we need to do before using these filters is isolate the sky, then effectively hide the edge of the sky from any filter we might use to enhance local contrast.

 

We want a convincingly realistic enhancement of the sky without any odd transition artifacts—like this:

 

This tutorial will show you how to do this.

 

So we start by isolating the sky (we were going to have to do this anyway to protect the foreground from the enhancing operations performed on the sky.)  You could use many techniques including many available plug ins that are available for purchase.  However, I like the background eraser and in this example—it’ll be very quick and easy.  (For more advanced situations, the background eraser will be the only option that produces clean enough results.)

 

For Photoshop, set the sampling to “once” and the limits to “discontiguous”.  You will use the number keys to set tolerance (1 = 10%, 5=50%, etc…)  It’s pretty easy to iteratively figure out the right setting—just hit a number and click the brush near the edge of the sky to see how it works.  I started with about 50 or 60% tolerance up where the sky is brighter.

 

(Note I’ve made a copy of the original and am working on that—this layer will be referred to as “background copy”.)  Then gradually went do to 20% (in 10% steps of course) as I approached the bottom.  Just a few minutes to paint all the way across with a large soft brush.

 

For Paintshop Pro, use the same settings (sampling = “once”, limits = “discontiguous”).  Paintshop Pro is able to automatically set tolerance, so I’d use that.  The background eraser in Paintshop Pro has more controls than the one in Photoshop.  There's a great tutorial for the Paintshop Pro background eraser, but it's not okay to put links in tutorials, so you can just email me for the link if you're interested.

 

Then use the polygonal lasso tool to quickly remove the rest of the sky.

 

Now we have a layer with only the foreground—the hazy background has been erased.  We actually want the opposite.  We want only the hazy background.  In Photoshop: 

 

1. Ctrl-click the thumbnail of the background copy (converts the opacity into a selection giving you a selection that corresponds to the foreground)

2. Ctrl-shift-I (inverts the selection so now you have a selection corresponding to the sky)

3. Go to the channel palette and click the “save selection as channel” button to save this selection (we’ll need it later).  Note it’s called “alpha 1”.

 

4. Return to the layer palette and select the background.

5. Ctrl-J.  (creates a new layer with only the sky.

6. Ctrl-D (clear the selection.)

 

In Paintshop Pro you must first create a mask from the opacity of the background copy.  Then save this mask into an alpha channel.  Then load it back as a selection.  Then select a layer with the full copy of the original image and hit delete (which deletes all but the sky).  (I apologize for not being as meticulous for the PSP instructions—hopefully get to that later.)

 

So here’s where we are at:

 

I removed the background copy (we don’t need it any more) and have labeled our sky-only layer as “sky copy”

 

Now make a copy of the sky and apply a Gaussian blur (I used radius 50—when the tutorial is complete, you’ll understand how to choose this radius.)  This layer is called “sky blur”.

 

Now make 20 (or so) copies of this layer (ctrl-J repeatedely).  What this is doing is increasing the opacity of the blurred sky.

 

Now merge all of these blurred sky layers and put the result underneath the unblurred “sky copy”:

 

What we now have is our original sky (including sky and background terrain) surrounded by a smooth extension of the sky and background terrain.  This smooth “buffer zone” will allow us to now apply our large radius USM or clarify filter (or just about any other operation) without having to worry about the halo or any other transition artifacts.  Go ahead and merge the “sky copy” and “sky blur merge” into one layer (call it “sky copy”)

 

Now go back to the channel palette, ctrl-click the saved alpha channel (alpha 1 gets converted into a selection), return to the layer palette (make sure “sky copy” is selected), then click the “add layer mask” button to create a mask from this selection.

 

Now we are sort of back to where we started—you can see the original image and original sky except now the original sky is on a separate masked layer with the all-important “buffer zone” hiding behind the mask.  Now we can being fixing the sky.

 

Naturally, the first thing we want to do is the large radius USM.  In this case, I used radius 30 and strength 100 (relabeled the layer accordingly).  Paintshop Pro users might want to use the clarify filter (although for this example, I found clarify boosts noise quite a lot, so use it carefully.)

 

It’s getting better, but we still have a few more tricks.  Next, create a curves layer.  Copy the mask onto this new layer (you can press the alt key, then click and drag the thumbnail from the “USM 30/100” layer and drop it right onto the levels1 layer.)

 

A big problem with the sky is it’s filled with scattered light which makes it too bright.  This type of curve darkens the sky and boosts contrast at the same time giving the result above.

 

Next, add a warming photo filter to warm up the mountain and background terrain which have been made a bit too blue.  This is a common occurance and is due to the same light scattering that makes the sky blue.  I just used the default warming filter 85 with 25% density.  Alt-click drag and drop another copy of the mask onto the photo filter. 

 

In this case we want to warm everything except the sky, so select the photofilter mask and press ctrl-I (inverts the mask).  Now it’s warming just the foreground.  With the mask still selected, get a large, soft, white brush and paint white on the mask over the mountain (when you have the mask selected, painting on a layer paints on the mask instead of the layer itself.)  Notice in the figure the mask is only black over the sky which means the filter is warming everything except the sky:

 

In some cases, you might well be done at this point.  However, the USM and curve we applied in this example is relatively extreme and amounts to considerable amplification of the color information which results in the sky being visibly grainy. 

 

So make a merged copy (ctrl-alt-shift-E).  I then apply a surface blur filter (similar to edge-preserving smooth in Paintshop Pro) to smooth out the sky.  I used radius 9, threshold 7 in this case.  This smooths the foreground a bit so, once again, alt-click and drag yet another copy of the mask onto this layer to confine the blurring to the background area.  Then I select the mask (by clicking the mask thumbnail), grab a medium grey paintbrush and paint over the mountain to partially reduce the effect of the surface blur on the mountain itself.

 

And now we’re done: