Unsharp mask

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

Stanley
Posts: 83
Joined: Sun Aug 02, 2009 2:34 pm

Unsharp mask

Post by Stanley »

Hi everyone,

I have this question:

If you use the unsharp mask in Photoshop Elements, or in general if you adjust sharpness, is that considered interpolation?

If it is, my tendency would be to avoid it for my photos. The problem is that unsharpening sometimes really does makes a crisper picture.

What are your thoughts on this?

Thanks.

Stanley

rjlittlefield
Site Admin
Posts: 23562
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

No, sharpening in general and unsharp mask in particular are not interpolation.

Interpolation kicks in when the image has to be resized in some way that some of the pixel centers don't line up, say from 600 pixels down to 500.

An easy way to see the difference is to imagine an image that's a uniform checkerboard of pixel values, say:

... etc
... 050 200 050 200 050 200 ...
... 200 050 200 050 200 050 ...
... 050 200 050 200 050 200 ...
... 200 050 200 050 200 050 ...
... 050 200 050 200 050 200 ...
... 200 050 200 050 200 050 ...
... etc

If you sharpen this image, the light values will get lighter and the dark values will get darker, but all of the light values will stay equal and so will all of the dark values.

On the other hand, if you interpolate this image from 600 to 500 pixels, then some of the pixel centers will line up and some of them won't. You get weird mixing of the values, it's different from place to place, and if the target image is smaller (as in this case) then you lose information.

For example, depending on the interpolation algorithm (this one is Photoshop's "bilinear"), you might end up with this:

.. etc
... 083 156 133 108 177 ...
... 156 121 133 145 108 ...
... 133 133 133 133 133 ...
... 200 050 200 121 156 ...
... 177 108 133 156 083 ...
... etc

Visually, it looks like this:

Image

Bottom line, you should be much more nervous about interpolation than about sharpening.

Interpolation by ratios close to 1 is almost guaranteed to do something you won't like if you have pixel-level detail.

Sharpening is pretty safe, except that excessive sharpening can give you things like halos and a generally artificial appearance.

Almost everything I post has been sharpened. Sharpening can make a dramatic improvement in the amount of detail that is visible to the end viewer.

--Rik

DaveW
Posts: 1702
Joined: Fri Aug 04, 2006 4:29 am
Location: Nottingham, UK

Post by DaveW »

What is the difference then between Photoshop Elements "Unsharp Mask" and "Adjust Sharpness" then? I am now tending to use the latter more than Unsharp Mask.

I presume they must work slightly differently?

DaveW

BJ
Posts: 355
Joined: Sat Sep 29, 2007 10:53 am
Location: England

Post by BJ »

Rik,

thanks for a clear masterful explanation.

Ciao
Brian

rjlittlefield
Site Admin
Posts: 23562
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

Brian, thanks. I learn a lot by writing these things.

Dave, who knows? Every filtering scheme is a little different under the covers, and unless the vendor publishes the algorithm, it's just gut feel and guesswork about what actually happens.

You can't even trust the names.

As an example of how weird things can get, let me illustrate the results of 5 different interpolation algorithms used to resize a 120x120 nested checkerboard down to 100x100. These are all displayed at 200% -- two monitor pixels for every image pixel. The inner checkerboard is 1 pixel, the outer is 4.

Image

Now, I know for sure what Zerene Stacker is doing because I wrote that one. It's a classic 4x4 cubic spline interpolator, described HERE as "Spline16".

Exactly what each of Photoshop's algorithms is doing, I simply don't know. The "Bilinear" result looks like what I'd expect from a classic bilinear with a partial-pixel offset, but I haven't carefully checked the numbers. Things start getting weird with the "Cubic" result --- it's sharper than bilinear for the coarse part but oddly gray and uniform in the fine part, clearly not a classic cubic interpolator. Then it's no surprise that the "Bicubic Smoother" result is smoother in both areas, but it's a huge surprise that the "Bicubic Sharper" result is sharper for the coarse part and smoother for the fine! (Yes, I know this is hard to believe. That's why I checked it three times. This is Photoshop CS, Version 8.0. Your mileage may vary, and if so, I'd like to hear about it.)

OK, interpolation is not filtering, but hopefully this illustrates the point that trying to answer "what is the difference?" is fraught with peril. Clearly Photoshop is not doing exactly what the names would suggest. Maybe their implementors decided that aliasing is a bad thing, and threw in some code that avoids aliasing at the cost of losing all hint of texture. If that's the case, it doesn't work --- the thing still aliases like crazy at 95% instead of the 83.33% used above. Heck, for all I know, maybe they have a special "checkerboard detector" that does something weird just to tease people like me. There's no way to tell, and it probably doesn't matter. The algorithms do what they do, and people figure out from experience which one works best for their own images and purposes.

Getting back to your question, you say that you're now tending to use Adjust Sharpness more than Unsharp Mask.

I'd be interested to know why that is. I have no experience with Adjust Sharpness. I suppose that either you get better results, or you find that Adjust Sharpness is easier to use. Explaining and illustrating differences at that level would be far more useful than anything more technical.

--Rik

Joseph S. Wisniewski
Posts: 128
Joined: Fri Aug 15, 2008 1:53 pm
Location: Detroit, Michigan

Post by Joseph S. Wisniewski »

I've always considered sharpening to be a form of interpolation, in that it creates "high frequency content" (aka "detail") that did not exist in the original image. Here's a (radically? criminally?) oversimplified explanation...

Unsharp mask is an ancient sharpening method: it can be done completely analog, with copy negatives in the darkroom. It's a single pass, small convolution. That is, it performs some math equivalent to blurring the image slightly, then subtracting the blurred image from the original image. (In the darkroom, you blur the image, print it to negative film, sandwich the blur negative with the original negative, and print again). If you guess right with how the image is blurred, removing the "fake" blur should sharpen the image.

"Smart Sharpen" (full PhotoShop) and "Adjust Sharpness" (Elements) are iterative deconvolution, that is, they sharpen a bit, check to see how the detail looks (according to some wild programmer's concept of what "good" detail looks like) and then sharpen again until it looks right. This is more similar to what is done in astronomy or image restoration, and is a lot like approximating high order splines by repeated passes of a lower order spline.

DaveW
Posts: 1702
Joined: Fri Aug 04, 2006 4:29 am
Location: Nottingham, UK

Post by DaveW »

The difference between digital and film is hopefully film should always be sharp out of the camera and not require sharpening, whereas digital images are intentionally softened in camera to avoid moire patterns and then "pseudo sharpened", either in camera for JPEG's, or in post processing if using RAW. I say "pseudo sharpened" since as I understand it you can never put back the information that was removed in the softening process, only simulate it?

I did a Google search for "Adjust Sharpness" in Elements and it seems to be a detuned version of "Smart Sharpen" as you say in Photoshop and most reviewers seem to think it is better than "Unsharp Mask" since there are less chances of getting sharpening halo's.

http://graphicssoft.about.com/od/pselem ... rpness.htm

Scroll down to p207 on this link below to see an example of "Adjust Sharpness".

http://books.google.co.uk/books?id=AQzP ... q=&f=false

One person on another site says:-

"But for just touching up the sharpness of a normal image then Adjust Sharpness is the best - but make sure you have it set to Lens Blur (or motion blur if that's what caused the blurring). Adjust Sharpness is the same as Smart Sharpen in Photoshop - but you just get the Basic and not the Advanced panel (so don't get a choice of being able to sharpen highlights, midtones and shadows separately)."

For "Smart Sharpen" see:-

http://www.earthboundlight.com/phototip ... -more.html

DaveW

Stanley
Posts: 83
Joined: Sun Aug 02, 2009 2:34 pm

Post by Stanley »

Hi everyone,

As much as I have tried, I still don't understand how the overall process of sharpening works.

Here is a link to the Wikipedia article on "Unsharp masking":

http://en.wikipedia.org/wiki/Unsharp_masking

And here, I think, is the nub of the issue:
Because the positive has been intentionally blurred, only the low frequency (blurred) information is cancelled. In addition, the mask effectively reduces the dynamic range of the original negative. Thus, if the resulting enlarged image is recorded on contrasty photographic paper, the partial cancellation emphasizes the high frequency (fine detail) information in the original, without loss of highlight or shadow detail. The resulting print appears sharper than one made without the unsharp mask; the apparent accutance is increased.
I am sure that it is a fine explanation, but if someone could explain it in different words, then maybe I would finally get it.

Thanks to all.

Stanley

rjlittlefield
Site Admin
Posts: 23562
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

I read on your web page that you have a math background. So try this description...

Think of your image as a sum of low and high frequency components.

To sharpen it, you want to make the high frequency (H) components stronger without changing the low frequency (L) components.

Unsharp mask does this as follows.
  • Start with the original image: L+H
  • Blur it: L+H becomes (for example) L+0.5H
  • Make a lower contrast mask from the blurred version: 0.8*(L+0.5H) = 0.8L+0.4H
  • Subtract mask from original: (L+H) - (0.8L+0.4H) = 0.2L+0.6H
  • Increase contrast of result as needed to restore L: 5*(0.2L+0.6H) = L+3H
The result image has the same low frequency components as the original, but the high frequency components are now stronger. It looks sharper.

In terms of this description, unsharp mask is typically controlled by two parameters: where the break is between L and H in frequency domain, and how much H gets increased. In Photoshop, these are called "Radius" and "Amount".

In practice, there is a gradual transition rather than a sharp break between L and H. But the general principle of unsharp mask is the same: first use a blur to reduce the high frequency components, then scale and subtract to reduce the low frequency components more than the highs, then rescale to restore the lows and amplify the highs.

Other filtering approaches use different math to accomplish very much the same goals: make the high frequency components stronger while leaving the lows unchanged.

--Rik

DaveW
Posts: 1702
Joined: Fri Aug 04, 2006 4:29 am
Location: Nottingham, UK

Post by DaveW »

No doubt I have got it wrong, but I understood digital sharpening worked similar to the old chemical acutance developers with film, in that at an edge it locally darkened the darker tone and lightened the lighter tone for a few pixels, thus making the edge seem more distinct and hence sharper?

I found this blow-up of the effect of a chemical acutance developer increasing edge contrast on the Web (acutance developer on right hand side):-

http://static.photo.net/attachments/bbo ... 249684.jpg

There is a good multi-part article on sharpening here:-

http://www.ronbigelow.com/articles/shar ... arpen1.htm

DaveW

rjlittlefield
Site Admin
Posts: 23562
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

DaveW wrote:digital sharpening worked similar to the old chemical acutance developers with film, in that at an edge it locally darkened the darker tone and lightened the lighter tone for a few pixels, thus making the edge seem more distinct and hence sharper?
There are both similarities and differences.

High acutance film development relies on a combination of chemical depletion and physical diffusion. In heavily exposed regions the developer depletes, while in lightly exposed regions it does not. Diffusion of the developer smears its concentration over small regions ("a few pixels"). As a result, in the vicinity of an edge, the heavily exposed regions develop more than usual while the lightly exposed regions develop less than usual. The result is to enhance the edge. In this respect, high acutance film development is similar to what an unsharp mask will do.

However, high acutance film development is a highly nonlinear process --- it enhances strong edges disproportionately more than weak edges of the same size. This is very different from unsharp mask, which enhances all detail at the same scale by the same amount.

Digital sharpening, of course, can mimic either of these effects and many more.

Thanks for the reference to Bigelow's article. Many good issues and ideas raised in there.

--Rik

Stanley
Posts: 83
Joined: Sun Aug 02, 2009 2:34 pm

Post by Stanley »

Hi Rik and everyone,

Let me parse out all your steps against the background of the Wikipedia article.

Rik's Step 1:
Start with the original image: L+H
So far, so good.

Wikipedia writes,
In the photographic process, a large-format glass plate negative is contact-copied onto a low contrast film or plate to create a positive. However, the positive copy is made with the copy material in contact with the back of the original, rather than emulsion-to-emulsion, so it is blurred.
Rik's Step 2:
Blur it: L+H becomes (for example) L+0.5H
Wikipedia continues,
After processing this blurred positive is replaced in contact with the back of the original negative. When light is passed through both negative and in-register positive (in an enlarger for example), . . .
Rik's Step 3:
Make a lower contrast mask from the blurred version: 0.8*(L+0.5H) = 0.8L+0.4H
So, for Step 3, is Rik describing mathematically what the Wikipedia article is stating in words?

And here is my second question on this part: If Rik's formula in Step 3 does pertain to the last quoted Wikipedia paragraph, does the coefficient of 0.8 produce a "lower" contrast mask? Would a coefficient of 0.7 make an even lower contrast mask, and a coefficient of 0.6 still lower? In short, I am asking whether 0.8 is the coefficient of blurring, so to speak.

Then, however, what about the 0.5 in Rik's Step 2? Which one (0.8 or 0.5) is the coefficient of blurring?

This line from Wikipedia must be relevant here, I think:
In the photographic procedure, the amount of blurring can be controlled by changing the softness or hardness (from point source to fully diffuse) of the light source used for the initial unsharp mask exposure . . .
Wikipedia proceeds,
. . . the positive partially cancels some of the information in the negative.
Rik's Step 4:
Subtract mask from original: (L+H) - (0.8L+0.4H) = 0.2L+0.6H
No problem here.

Finally, Wikipedia writes,
. . . the strength of the effect can be controlled by changing the contrast and density (i.e., exposure and development) of the unsharp mask.
Rik's Step 5:
Increase contrast of result as needed to restore L: 5*(0.2L+0.6H) = L+3H
So here, multiplying by 5 is the mathematical equivalent of increasing the contrast and density of the unsharp mask, right?

I hope I have stated my questions well. I am trying to match Rik's various formulas with the verbal description in Wikipedia.

Thanks to all.

Stanley

rjlittlefield
Site Admin
Posts: 23562
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

Stanley,

I'd like to give you an accurate and concise mathematical model of how unsharp mask works in a darkroom. Unfortunately, no such model exists because there are nonlinear responses at every step of the process. If the original image is L+H, then a negative of that is not -(L+H) but rather some ugly f(L+H) where the derivative of f happens to be negative even though f itself is probably positive! Something like that happens for every step of the printing process, so making a blurred positive from a negative is actually some ugly function of a convolution. And sandwiching negative and positive film images isn't really modeled very well by addition, it's more like multiplication of the transmission coefficients.

What I was hoping to do with the math was give you a flavor of what's going on. If you think in terms of high and low frequency components, then the blurred mask reduces the high frequency components, sandwiching the blurred mask with the original negative gives you a low contrast image with high frequency components that are relatively enhanced (though still smaller than they started), and making a high contrast copy of that gives you an image with its low frequency components restored and its high frequency components amplified. In the algebra I gave, this is modeled by simple addition, subtraction, and multiplication. But no digital "unsharp mask" operation exactly mimics any darkroom process, it just preserves the general flavor of the operation.

Having warned you that this all approximate, let me now try to put it into correspondence with quotes from the Wikipedia article.

I said "Start with the original image: L+H"

Wikipedia starts with a negative. That would be roughly -(L+H). Then they say
In the photographic process, a large-format glass plate negative is contact-copied onto a low contrast film or plate to create a positive. However, the positive copy is made with the copy material in contact with the back of the original, rather than emulsion-to-emulsion, so it is blurred.
Using my numbers, what's being generated in this step is something like a blurred positive = 0.8*(L+0.5H)

Wikipedia continues,
After processing this blurred positive is replaced in contact with the back of the original negative. When light is passed through both negative and in-register positive (in an enlarger for example), . . .
So now we have the original negative -(L+H) plus the blurred positive 0.8(L+0.5H), giving -0.2L-0.6H = -(0.2L+0.6H) = -0.2*(L+3H). In other words, we have a low contrast negative of an image with enhanced high frequency components.

Wikipedia then closes,
Thus, if the resulting enlarged image is recorded on contrasty photographic paper, the partial cancellation emphasizes the high frequency (fine detail) information in the original...
It's assumed that the printing process is negative-to-positive, and "contrasty" means with an absolute factor > 1. In my example, the factor would be -5, hence the final image would be (-5)*(-(0.2L+0.6H)) = L+3H.

To my eye, all the negative signs just make the logic hard to follow, but if you're looking for exact correspondence with the Wikipedia article, that's what is required. Still, I'd rather drop the negative signs except one, and represent the overall process like this:

5*((L+H)-0.8*(L+0.5H)) = L+3H

Let's replace the magic numbers 5, 0.8, 0.5, and 3 with variables:

X*((L+H)-Y*(L+ZH)) = L+AH

If you slog through the algebra, you'll eventually figure out that X = 1/(1-Y) and also that Y = (1-A)/(Z-A).

So...

You pick an A based on what result you want, and you pick any one of the other three numbers X,Y,Z based on whatever you like. Once you pick one of X,Y,Z, the other two are determined by the constraints. It's a one-free-parameter problem. In the example, if A=3, then choosing Z=0.5 forces Y=0.8 and X=5. If I had chosen a different Z, then Y and X would have been different to match. For example if Z=0, corresponding to the blur being a perfect lowpass filter, then Y=(1-A)/(-A) = 2/3 in my example, X = 3, and the overall process looks like this:

3*((L+H)-2/3*(L+0*H)) = L+3H

I'm not sure what you mean by "coefficient of blurring", but I'm pretty sure I cannot tell you whether it's the 0.5, the 0.8, or the 5. They're all interrelated.

Regarding your last question, Wikipedia writes:
In the photographic procedure, the amount of blurring can be controlled by changing the softness or hardness (from point source to fully diffuse) of the light source used for the initial unsharp mask exposure . . .
This is roughly akin to choosing where to split the frequency domain between L and H. Using a diffuse light causes wide blurring, equivalent to making the break at lower frequencies, while using a point source causes narrow blurring, equivalent to making the break at higher frequencies.

--Rik

Stanley
Posts: 83
Joined: Sun Aug 02, 2009 2:34 pm

Post by Stanley »

Hi Rik,

Thank you. As always, a very instructive posting.

Stanley

Stanley
Posts: 83
Joined: Sun Aug 02, 2009 2:34 pm

Post by Stanley »

Hi everyone,

In another forum I am discussing the manipulation of color channels.

While that is going on, let me pursue the issue of sharpening. It is really bothering me.

Should I try to sharpen my photographs, or should I forget it? If I do try to sharpen, are there general guidelines as to how I know just how far I can push it? Let's assume that I don't have the subject in front of me.

I understand that, if I oversharpen, I am supposed to see halos. But I don't usually see them.

Thanks.

Stanley

Post Reply Previous topicNext topic