SLR CameraPoint and Shoot Camera
shaded top background

Theory and practice of sharpening


Sharpening - what it is and what it isn't

Sharpening is a very useful, but much misunderstood and abused technique. In this article I first want to introduce you to some theory behind sharpening which explains what it does and how it does it, and use that knowledge to explain the pitfalls in using sharpening, and why it can't do as much for your images as is sometimes imagined.

Then having looked at the theory, I'll go through a useful technique for applying sharpening selectively, and therefore prudently, in your image.


Some theory

Sharpening is all about fooling your eyes into thinking an image is sharper when it isn't! It's an optical illusion that takes advantage of how our vision works. We see an image as sharp when the boundaries between different colours or levels of luminosity (light and dark) are abrupt rather than gradual, and this is reinforced if the difference in colour or luminosity is greater rather than smaller. This is why a contrasty image (perhaps taken in bright sunlight) usually looks sharper than the same view taken under a grey sky, or more extreme, in mist.

Sharpening cannot make the change from light to dark, or colour to colour, more abrupt. (From now on I'm only going to talk in terms of light and dark, but everything also applies to changes in colour.) So an image that's not perfectly in focus, which means that changes from dark to light are more gradual, cannot be made in focus by sharpening, no matter how harshly you apply it. Sharpening works by artificially increasing the contrast across a dark to light boundary. It's important to realise that sharpening degrades your image by introducing distortions that weren't in the original scene: therefore we want to sharpen as little as possible whilst doing enough to trigger the optical illusion of sharpness that we're after.

Consider this fragment of an image of a church: Unsharpened fragment Imagine walking along the red line, starting at the dark end. As you walk along, all the pixels are pretty dark, and then suddenly they're all pretty light. I've represented this walk in the following bar chart. Each column represents the luminosity of a single pixel in the image. Luminosity is represented by values between 0 (pure black) and 255 (pure white). As we get to the boundary between light and dark, the luminosity suddenly increases. A perfect boundary would go straight from dark (luminosity 80) to light (luminosity 180) across a single pixel, but that doesn't happen in photography!

Graphic to illustrate a boundary

Some things to notice about this chart.

  • The edge stretches across 4 pixels, so that the last dark pixel is number 9, and the first light pixel is number 12.
  • The slope of the line drawn through the circle on the chart represents contrast. The steeper the slope, the greater the contrast across the boundary. If, for example, this jump in luminosity from 80 to 180 took place across 8 pixels instead of 4, the contrast slope would be much flatter, and contrast would be less.
  • The range of pixels over which the change of luminosity takes place represents the absolute sharpness of the image. As we will see, sharpening actually increases the width of boundaries and decreases absolute sharpness. Again, the apparent greater sharpness of a sharpened image is all illusion.

As I explained before, sharpening works not on the absolute element of sharpness (how abruptly we move from light to dark) but on the contrast element. I've represented this same edge after it's been sharpened by this second bar chart.

Graphic to illustrate a sharpened boundary

Some things to notice about this second chart.

  • The edge now stretches across 6 pixels, so that the last dark pixel is now number 8 and the first light pixel is now number 13. Remember that this is a simplified demonstration, and that reality is a bit more complex!
  • The first pixel of the boundary has been made darker, and is now 60, whilst the last one has been made lighter, and is now 200. Again this is simplifying reality!
  • The result of this is that the slope of the contrast line is now significantly steeper than in the first chart.

So although absolute sharpness has declined, with the change from dark to light taking longer, apparent sharpness has increased because the contrast across the boundary has increased. Like all optical illusions however, it only works up to a point. If we sharpen too much, we see not the illusion but the reality, which is that sharpening draws dark lines on one side of a boundary, and bright lines on the other side. If this takes place too much, we see sharpening "haloes" of white around all the boundaries, and the illusion breaks down.

This demonstration also helps us to understand how the settings in the unsharp mask dialog box work. Below is the unsharp mask dialog in the GIMP. My description of how the sliders work is again a simplification, and is illustrative only: however, it is a reliable guide to what the consequences of various settings will be.

Unsharp mask dialog

  • The first slider (radius) controls what is going to be considered an edge. The smaller the value here, the fewer must be the number of pixels across which a change from dark to light needs to take place if that change is going to be treated as an edge. If an image is actually out of focus, then nothing would be sharpened at the setting displayed here since an out of focus image has no sharp boundaries.
  • The second slider (amount) controls how much more the pixel before the edge is decreased in luminosity, and how much the one after is increased. In other words, it controls by how much the local contrast across the boundary is going to be increased, and thus the degree of apparent increased sharpness.
  • The third slider (threshold) controls how much more light or more dark adjacent pixels must be to be considered an edge. The greater the setting the less the amount of sharpening because fewer luminosity changes will be treated as an edge.


Real world sharpening

We started off by saying that human vision sees sharpness when edges are abrupt, and the contrast across them is great. From this we can see that ideally we want to sharpen only the edges in an image. Unfortunately there are other things in an image that are like edges, but which we want to see less of, not more of. The main example of this is noise. Digital noise in shadow regions of images that have been exposed with high ISO speed values (400 and above, for most cameras) can be very intrusive. Noise introduces lots of edges that we certainly don't want to sharpen! Applying unsharp mask values that will do the job for the edges we want will also be likely to do it for the edges we don't want. What follows is a technique that enables us to apply sharpening selectively to edges in the image, whilst leaving other areas of the image unaffected. This is not a technique that I've made up, but I have adapted it to my workflow, and I offer it to you in the hope that you can use my ready-made settings rather than having to research the method yourself.

I'm going to demonstrate the technique using one of my gallery shots, the one of Ealing parish church. Here's the image before sharpening.

Before sharpening

This technique works by finding the edges in the image, and then creating a selection from them so that when the unsharp mask is applied, it only works on the selected edges and leaves the rest of the image untouched.

It does this by:

  • Using the edge detection filter to find edges.
  • Using the levels dialog to home in on significant edges.
  • Using gaussian blur to spread the edges thereby making the selection slightly bigger than just the edges alone, otherwise the effect would be too harsh.
  • Copying the edges to another version of the image to which you have added a new channel.
  • Converting this new channel to a selection.
  • Applying this selection to a duplicate image layer.
  • Applying the unsharp mask one or more times to this selection.

If you want to "follow along" with one of your own images, you will need an image editing program that lets you work with layers and channels. Unfortunately PS Elements does not have channel functionality, so you will need full PS, or something like the GIMP which I'm using here. GIMP is free and can be downloaded from GIMP for Windows installers (http://http://gimp-win.sourceforge.net/stable.html).

Click on the link below for a step by step guide.

Sharpening page 2

shaded bottom background
spacer