An Introduction to Photoshop's Unsharp Mask


Status
Not open for further replies.

kelvinty

New Member
Feb 13, 2002
225
0
0
43
Dear folks,

Just finished the article on my pocketpc yesterday in camp, but as I had duty, and there wasn't a sync terminal in camp I couldn't post it up. Anyway, just arrived back home in the morning, and here is it! An introduction to Unsharp Mask. Please feel free to point out any errors or suggest any improvements! Also maybe you can share with us some tips on the usage of Unsharp Mask.

------------------------------------------------------------------------------------

Introduction to Unsharp Mask for Adobe Photoshop 6.

Kelvin Tan, Reload Studios
19th February 2002

One of the most commonly used filters in Adobe Photoshop 6 would be those that allows an image to be sharpened.

With these range of tools, a photographer can have a limited degree of control over the sharpness of his image. He can now sharpen to the desired level, and of course he can also inadvertently sharpen more than he wants - over-sharpening is the term.

Let's examine the concept of sharpness first. To explain in simple terms, sharpness refers to the degree of difference, or contrast, of pixels in an edge with its neighbouring pixels just next to the edge.

YYYYXXXOOO
YYYYXXXOOO
YYYYXXXOOO
YYYYXXXOOO
YYYYXXXOOO

Let's take X as the edge line, O and Y are adjacent pixels on both sides of the edge. Now the sharpness of the edge depends on two differences. The first would be the degree of difference in colour and brightness between let's say X and Y. If Y was white, and X was just a slightly grayish, the contrast between X and Y would be minimal. Thus when the pixels are viewed from afar (or zoomed out), the gray edge becomes hard to make out because the contrast between white and slight gray is extremely little. In this way, the edge will be soft. However, if Y is white, and X is black, the contrast would be extremely high. Hence, even when viewed from afar (or zoomed out), due to the high contrast between the white Y and the black X, the edge will be sharper than if X was gray.

On to brightness, now we'll take X and O as comparison, with X being the edge line again. If X is not very bright, and O is also not very bright, the contrast in brightness can be said to be low. As a result, when viewed from afar, the edge seems to be blur or hardly visible. However, if X is extremely bright, and O is substantially dark, then when viewed from afar, the edge X will stand out as a bright line among the dark Os.
Vice versa, if the Xes are dark, and the Os are bright, then when viewed from afar, the edge X will be a clear dark line, clearly standing out from the bright Os.

Now that I've tried to explain what actually constitutes the sharpness of a picture, let's head back to our main area of focus, the Sharpen group of filters.

What a Sharpen filter does, is to actually detect edges (by comparing neighbouring pixels in an image, if there is a substantial contrast in the brightness and colours of two neighbouring pixels, the filter will determine this as an edge. Now once it detect an edge, what it will do next is to increase/decrease the brightness and colours of the edge, hence increasing contrast. As explained above, this will make the edge stand out more, and in return sharpens the image.

Under Photoshop, it comes with a set of Sharpen filters under the menu FILTERS > SHARPEN. The Sharpen group of filters consists of Sharpen, Sharpen More, Sharpen Edges and Unsharp Mask.

So why Unsharp Mask? Only Unsharp Mask allows input of variables such as Amount, Radius and Threshold. The other filters are all fixed, and hence offer extremely limited control. Due to this simple reason, Unsharp Mask is _the_ way to go, what the rest can do, Unsharp Mask can do, and can do even more and better. So it's better that you constantly use Unsharp Mask, and hone your skills in it.

Let's now look at the settings the Unsharp Mask offers. When you activate the filter, a dialogue box will come up, with a small preview window, a checkbox labelled Preview, and 3 adjustable settings with sliders and inputboxes. We shall look at each of these in detail.

The small preview window will render the filter in almost realtime, and it will show only a section of the whole image. You can choose which section of the image appears by moving the mouse cursor while the dialogue box is up to any part of the image (when the cursor moves to the image it will change into a small box). Below the preview window is a percentage value with a + and - clickboxes by the sides. This will allow the preview window to zoom in the selected section of the image, which might prove useful if you really want to examine closely the sharpness of the edge.

The Preview checkbox is very simple to explain. Basically, when it is checked, any adjustments to the three settings Amount, Radius and Threshold will be rendered to the whole image which can be seen. If it is not checked, only the Preview window will show the rendering. The whole image behind the dialogue box will not get updated at all until the user press 'OK'. The advantage of using the Preview option is that you can see how the adjustments affect the image as a whole, but it might slow down the computer. What you could do is to uncheck the Preview checkbox, and use the Preview window to see the rendering, albeit to a small section only. Once you feel that the settings are alright and you want to see the rendering on the whole image, just check the Preview checkbox. Then if you are satisfied with it, just click 'OK'. However if you still feel further improvements could be make, just unclick the Preview checkbox, saving you a considerable sum of processing power, and adjust the settings, viewing the rendering in the Preview window alone.

Next we come to the three main settings: Amount, Radius, and Threshold. Amount is in a percentage value, and basically it refers to the percentage increase in the original colour and brightness settings of the edge. As explained above, the higher the contrast of the edge in comparison to its neighbouring pixels, the sharper it wll appear. So a 30% value will tell the filter to increase the settings by 30%, in effect the contrast between the edge and its adjacent pixels will be 130% of what it's original contrast was at.

Radius refers to the width of the edge. The lower the number, the thinner the Sharpened edge will be. Look below for an example.

ORIGINAL
yyyyXXXoooo
yyyyXXXoooo
yyyyXXXoooo
yyyyXXXoooo

Now image X is the edge. If you want the edge to be thicker and sharp, you'll have a higher radius value.

HIGH RADIUS VALUE
yyyXXXXXooo
yyyXXXXXooo
yyyXXXXXooo
yyyXXXXXooo

What the filter does is to replace some of the edge's neighbouring pixels to a similar colour and brightness to the edge's pixels, effectively enlarging the edge.

One can also reduce the width of the edge by giving a small radius value.

LOW RADIUS VALUE
yyyyyXooooo
yyyyyXooooo
yyyyyXooooo
yyyyyXooooo

As you can see, what the filter does is to convert the edge's outer pixels and replace them with pixels similar to the neighbouring pixels of the edge. With this, you can create extremely fine edges.

When playing with the Radius value, you must keep in mind what is the resolution of the picture, and what output will the picture eventually be made for (a photo print? On screen? For the web?) generally speaking, the higher the resolution of the image, the more the radius value should be. Especially when it comes to photo print, because if the edge is too fine, it may not show up on the photographs as printing normally requires high resolution.

Last but not least would be the threshold level. Another word for threshold would be tolerance. This value actually tells the Unsharp Mask filter where to sharpen and where not to touch, or to tolerate. This value relates to the contrast between neighbouring pixels. As I've explained earlier, the pixels of edges are defined by contrast of colours and brightness with its neighbouring pixels. Now with a threshold level of 0, even if there is no difference between the colour and brightness of two adjacent pixels, the Unsharp Mask filter will attempt to sharpen them. It sounds contradictory, for if there's no contrast it can't be an edge, and if there's no edge how can it be sharpen. Well the picture will turn slightly grainy in some instances, due to the attempted sharpening of every pixels. However, if you were to set a higher threshold value, say of about 10, the Unsharp Mask filter will find edges by comparing the colours and brightness levels of adjacent pixels, and any pixels with a difference of 10 or more, the Unsharp Mask filter will recognize as an edge, and will sharpen only that edge accordingly. Any pixels with a difference in colours and brightness levels of less than 10, the Unsharp Mask filter will not touch.

By playing around with these 3 settings, you can have a high degree of control and customizability over how to sharpen your image. In a standard sharpening process, basically it goes like this :

1) find edges (by comparing the colours and brightness levels of adjacent pixels.)

2) increase the contrast (by increasing the colours and brightness of the pixels edge-side).

You can of course use Unsharp Mask alone, but alternatively, you may be able to boost its effects by supplementing it with other filters. Read up beyond this introductory article to Unsharp Mask, there are a lot of resources floating around on the Net.

Yet, one of the most important and effective supplements you can utilize in employing Unsharp Mask would be something you have ever since you were born. Try to locate it between your ears. ;P

Yours,
Kelvin

------------------------------------------------------------------------------------
 

kelvin,
dont fully agree with you on the Radius explanation - having a smaller radius DOES NOT make an edge thinner. The radius amount signifies how much of the SURROUNDING pixels to take into account and adjust during the USM process. Using your examples

ORIGINAL
yyyyXXXoooo
yyyyXXXoooo
yyyyXXXoooo
yyyyXXXoooo

USM here with a radius of 2 will modify 2 surrounding pixels (not literally, just as an example)

HIGH RADIUS VALUE
yyyzxXXXxaoo
yyyzxXXXxaoo
yyyzxXXXxaoo
yyyzxXXXxaoo

here zx and xa signify the changes made and in most cases, these pixels will have different color and brightness values - these pixels are the ones that give the "edge" to the line.

In ALL cases, USM will "fatten" the line (XXXX), not made it thinner.

For a clearer article on USM, with a working tutorial, go here:-
USM Technical Article
 

Dear folks,

Thanks for the pointing out the mistakes so far and the links to some really great articles. Now I are learning!! (and also learning how an ignorant twat I am actually. :p) Anyway I tried to explore USM in a pixel perspective, not an overall picture. Here is the experiment :


ORIGINAL NON-NOISE
NO USM
Original-vi.gif


USM : (A)mount 100 (R)adius 1 (T)hreshold 0
a100r1t0-vi.gif


USM : A 300 R 1 T 0
a300r1t0-vi.gif


USM : A 100 R 0.5 T 0
a100r05t0-vi.gif


USM : A 100 R 3.0 T 0
a100r3t0-vi.gif



As can be seen, Darren was right, the Radius setting of 0.5 doesn't 'shrink' the edge, however, also a high radius setting doesn't convert the adjacent pixels to the edge's colour! Rather it deepens the contrast of the adjacent pixels to similar coloured pixels, in effect creating somewhat another edge (notice the light green 'halo' around the edge now?)

In all cases, USM doesn't really seem to 'fatten' the line. I counted the pixels (trust me!) there were no adjacent pixels added to the edge (fattening) but there were some adjacent pixels given a slight boost in their brightness and colour value, however they still go along the lines of their original colour, not the edge's.

Any comments?
 

Status
Not open for further replies.