Understanding Unsharp Mask

Last updated: 13 May, 2007

A Simple Experiment

Almost everyone uses unsharp mask for sharpening their images, but hardly anyone fully understands this filter and its three parameters: amount, radius, and threshold. In order to learn more about unsharp mask, lets look at a very simple image that consists of two adjacent grey areas: a dark one with RGB values (64, 64, 64) and light one with (191, 191, 191).

Fig. 1: Unsharpened image.

The border between the two ares looks already pretty sharp, but what happens if we run the unsharp mask on this image? Let's do a few experiments and see what can we learn from them...

I've prepared three images, each containing a sharpened version of the image from Figure 1. Common to all three is a threshhold of 0 and an amount that increases from 0% (minimum value) from top to 500% (maximum value) bottom of each image. The images differ only by their radius values: 0.5, 1.5 and 5 pixels.

Fig. 2: The initial image sharpened with radius of 0.5, 1.5 and 5 pixels. In each image the amount increases from top to bottom from 0% to 500%.


To my eyes the top portions of all four images look identical. As I look further down the sharpened images, I start to see a stronger separation between the dark and light areas. By looking at the last image, I start to get an idea of how unsharp mask works — it increases the contrast around neighbouring pixels that already contain some contrast. In other words, the unsharp mask worked along the dark-light border, but changed nothing in the other areas of the image.

In order to gain further understanding of the process, I plotted the luminocity values of the pixels along the bottom edge of the image sharpened with radius of 5.

Fig. 3: Luminocity of the unsharpened (blue) and sharpened edge (red).

Apparently the filter made the dark pixels that lie in the proximity of light ones darker, and the light ones that lie in the proximity of dark ones lighter. It also produced a sort of a ripple-effect outwards until the sharpened values converged to the non-sharpened ones. Visually this makes the edge more visible and the ripples add a sort of "secondary edge", like a halo around the sharpened edge. That's it — that's the entire mystery of unsharp mask!

The Parameters

Fig. 4: Luminocity of the unsharpened (blue) and sharpened edge (red).

The amount of luminocity-change, or how much darker the dark pixel become and how much lighter the light ones become. Too small amount leaves the image soft.
The width of the affected area. Note that the radius is not measured in pixels but in some unknown units. If you don't believe me, look very closely at the image sharpened at 0.5 pixels. You will see that pixels more than one pixel away from the dark-light transition were affected. To high radius causes unnatural halos around details.
The minimum difference of luminocity of two neighbouring pixels so that the unsharp mask affects them. Too small threshold not only sharpens the image but also the grain. Experiment with this value until you find the optimal value.

Lessons Learned

The unsharp mask:

If it Sharpens my Image, why is it Called "Unsharp"?

Increasing the contrast along edges in order to increase the apprent sharpness of an image has its origin in the days of celuloid film. To achieve this increased contrast, a photographer apparently reproduced his negative onto a positive film slightly out of focus, placed the original and the copy on top of each other and printed from this layered negative.

http://photo.BDimitrov.de/ - Essays - Understanding unsharp mask
Copyright © Bojidar Dimitrov, All Rights Reserved.