Petteri's Pontifications
My musings about photography, mostly.
RSS feed
Sharpening

Sharpening

One of the most frequently-used yet most commonly misunderstood post-processing operations has to be "sharpening" -- technically "unsharp masking" or USM for short. The confusion is due to a lack of understanding of the difference between resolution and accutance, and what the parameters (amount, radius, threshold) actually mean. This has led to a proliferation of dumbed-down sharpening tools that get better results than just some random application of USM, but rarely as good as doing the job yourself with some understanding of the process. This is also why non-SLR digicams apply much too much sharpening in-camera.

This lesson will explain these concepts, how unsharp masking affects them (or not), and describe two different purposes for which unsharp masking can be used. After mastering these, you will be able to turn down sharpening to the lowest level in your camera and apply it yourself later, which will make your pictures visibly better and more "professionally finished".

Sharpness, resolution, and accutance

When we perceive an image as sharp, we're actually dealing with two separate issues: resolution and accutance (aka contrast). Resolution means how small detail a lens/sensor can record. Accutance means what is the lowest tone difference a lens/sensor can record.

A lens/sensor with high resolution but low accutance will produce images with lots of detail, but the detail won't be easily apparent because the differences in tone that make it up will be "flattened": images may end up with a muddy or "flat" look.

A lens/sensor with high accutance and low resolution will produce images where the detail is very clearly visible, but there may not be as much of it recorded as with the high-resolution, low-accutance lens/sensor. These images can actually have more "snap" and look sharper and more detailed than the higher-rez but lower-contrast images produced by the previous system.

Now, resolution can't be artificially increased: detail that isn't recorded can't be pulled out of thin air. However, accutance can. This is what unsharp mask does: it increases the brightness differences between adjacent areas. As long as the detail was captured (i.e., the tonal difference was above the absolute minimum that the system can record), it can be "brought out".

So, judicious use of unsharp mask will improve the accutance of an image, which will make the detail that was already in it more visible. Overuse will cause "sharpening haloes," aliasing, or other nasty side-effects (which can't easily be undone). This is why higher-end cameras generally apply less USM in-camera than consumer cameras: the advanced photographer is more likely to want to capture the best possible original where s/he can adjust the image (using USM, among other things) for maximum effect and minimum negative impact, whereas a "consumer" will probably not know how to use USM properly, or will not want to post-process the images at all.

What does USM do?

Unsharp mask increases the accutance of an image by boosting contrast between adjacent areas. The size of the change is proportional to the existing differences: a completely uniform area will not be affected at all, whereas an already high-contrast area will be affected most. The way it does this is determined by the parameters: amount, radius, and threshold. The amount sets how much USM changes the contrast. The radius determines how far USM looks from each pixel to make the adjustment. The threshold means how much difference it looks for to make any change at all. Each of these impacts the picture in a specific way.

Of the three variables, Radius is the pivotal one: it determines the type of impact USM will have.

What to watch out for: haloes, noise, and aliasing

Unsharp mask has some common undesirable side-effects: it can produce haloes (most commonly light "glows" around dark details) and accentuate noise. Very low-radius USM can also cause aliasing -- increase in contrast to the point that fine detail is compressed to the level of individual pixels, which show up as jaggies. Aliasing is an issue for pictures downsampled for the web only; full-size pictures aren't sharp enough to start with to produce this phenomenon before being completely ruined by haloes. (Pictures from the Foveon sensor are a notable exception.)

So, once you see haloes, a big increase in noise, or jaggies, you know you've overdone it.

You can see greatly exaggerated side-effects of USM in the above picture. The (downsampled) unsharpened original is in the top strip. Below that is as close to "optimal" sharpening as I could manage: the picture is sharp, but artifacts are not bad enough to be distracting (although you can see some if you look for them). Below that is a strip that has been way oversharpened at a very low radius, causing jaggy, harsh lines, and at the bottom is the "classic" over-sharpening -- too big radius, too high amount, leading to haloes. Look especially at the two badly-sharpened areas, and see how the radius affects the look of the artifacts.

Setting the variables

The larger the radius, the more variation there's likely to be, and therefore, the more visible the impact. So, USM with an amount of 100 and radius of 2 pixels will impact a picture much more than an amount of 100 and a radius of 0.2 pixels. The lower the radius, the higher the amount needed to make a visible difference, and vice versa. So, the first thing to remember when applying USM is to leave amount as a "loose variable." Threshold is another loose variable: it stops USM from affecting areas with little contrast. Boosting the threshold can be used to dampen the noise-enhancing effect of USM.

Radius, amount... And artifacts

Unsharp mask is applied to each pixel in turn. You can think of each dark pixel as "sucking" colour from lighter areas around it, to the distance set by the radius, and each light pixel as "sucking" lightness from darker areas around it. This explains the most common and most unpleasant artifact caused by USM: the sharpening halo. It shows up as a lighter "glow" around dark areas, or less obviously as a dark shadow around light areas. USM with too big a radius and too high an amount will produce such a halo. Instead, it will accentuate noise, and will have no effect on areas that aren't already pretty sharp. So:

USM rule 1: use as small a radius as you can...

(...and boost the amount until it looks good.)

If a picture already has high resolution, such as a photo that has been downsampled (shrunk) to WWW size, you can get away with extremely low radius and high-amount sharpening: I usually use 0.2 pixels and 500%, sometimes twice in a row.

However, this does not work for all pictures. For example, full-size out-of-the-camera or out-of-the-scanner pictures don't have as good resolution per pixel as downsampled images: when viewed at 100%, they look blurrier and softer. Therefore, you'll need to increase the radius until it's about half the "blur distance" in the picture, and turn down the amount to match. For these pictures, a radius of 0.7 pixels and an amount of 115% or so could be a good starting point... but watch out for those haloes; any radius starting from 0.5 pixels can create them.

So, radius and amount have a relationship: change one, and you'll have to change the other to keep a similar impact on the picture.

USM Rule 2: set the threshold as high as you can

Threshold determines the minimum contrast difference that USM will "grab". If set to zero, it will accentuate any differences at all. This will have the side effect of considerably aggravating noise/grain. Since the perception of sharpness is usually derived from edges and areas that already have some contrast, you'll want to boost the threshold so that most of the noise will be left unaffected, yet the picture will be optimally sharpened. So, once you've set the radius and amount to get the sharpening you want, nudge up the threshold to just below the point that it cancels out the sharpening.

Recap: how to sharpen with USM

Here's the normal sequence for finding the proper amount of USM to apply to a picture:

  1. Think of what you want to do.
  2. Set an Amount that's big enough for you to see the effects of Radius.
  3. Set a Radius that gets you the effect you want.
  4. Set a Threshold that minimizes the impact on noise.
  5. Turn down the Amount so you get the level you want with acceptable haloes or aliasing.

An extra twist: de-fogging

Unsharp mask can be used for other purposes than simply sharpening the picture. One way can be described "de-fogging". It simulates the optical qualities of extremely high-quality lenses, canceling out some of the "fogginess" introduced by complex zoom lenses with lots of lens elements and surfaces. Here, we're not trying to sharpen small detail, but increase the contrast between large areas of the picture. You can apply it in addition to the normal, low-radius sharpening described above. Here are the settings: Amount: ca 20% (very low) Radius: ca 60 px for 5-MP image (very high) Threshold: 0

It will have an effect of "scrubbing" the picture. It's best to do this before curves or levels adjustments, as it will increase the spread of the histogram, and can result in blown highlights or clipped shadows. (See the Levels lesson for an explanation of this.) The effect is very subtle, but it does make a difference.

When to apply USM?

It's best to apply the "sharpening" USM as the last thing before printing or publishing on the Web. The effects of USM cannot be fixed, and the amount of USM required depends on the picture. However, the "de-fogging" USM is best applied as the first thing, as otherwise you risk inadvertently clipping the highlights or the shadows.

Assignments

  1. Pick a picture. Downsample it to web size, and use USM on it to get it to optimum sharpness. Describe the settings you used, and how you arrived at them.
  2. Pick a picture. Use USM on it to optimize the sharpness on the full-size example. Crop a (max) 400 x 400 pixel area of it before and after sharpening, post, and describe the settings you used and how you arrived at them.
  3. Pick a picture. De-fog it with USM. Downsample the "before" and "after" versions to 400 pixels wide, sharpen the "after" version, and post. Describe the settings you used and how you arrived at them.