Sharpening


Posting rules: It shouldn't need saying, but... play nice. Please keep your discussions civil. You can disagree, just don't be disagreeable. And, of course, all of the usual stuff like no spamming. Tex adds: I'll be rigorously enforcing this as we go along. We're probably going to be a small community in a little lifeboat, so we can't have members at each others' throats. This is for the sake of the project as a whole. So when you post, pretend you're speaking in person with your very wealthy auntie who has always treated you wonderfully and currently lists you prominently in her will. I won't be tossing anyone out of the forums because we are all in this together (except spammers: immediate membership cancelation), but I'll delete suspect posts right away.


20 posts / 0 new
Last post
Doug
Sharpening

The topic of sharpening is an interesting one. A lot has been written about it, and by people more knowledgeable than I am. Jeff Schewe has built on the work of the late Bruce Frasier to create a 360-page book on sharpening:
Real World Image Sharpening with Adobe Photoshop, Camera Raw, and Lightroom (2nd Edition).
Nevertheless, I thought I'd stick my nose in the tent.

The Unsharp Mask

LightZone 3.9 only provides one kind of sharpening tool: the classic Unsharp Mask (USM) technique. So that's what I'm going to be concentrating on.

First, let's get a bit of photo myth out of the way. Many people claim that USM doesn't sharpen, that it just gives the illusion of sharpness. On the contrary, USM does sharpen. Sharpness is (roughly) defined as contrast at an edge, and that's what USM enhances. What USM doesn't do is to restore the original image precisely, as if it'd been captured with complete sharpness. Used intelligently, USM can come pretty darned close, though. The deconvolution approach to sharpening, used by Focus Magic, can come even closer.

A simple working explanation of USM is that it exaggerates the difference between the level of each pixel and the average level of the pixels in its neighborhood. The size of the neighborhood is set with the Radius slider, and the extent of the exaggeration is set with the Amount slider. There's also a Threshold slider that causes USM not to exaggerate small differences, which are (we hope) noise.

A more complex explanation is that USM sharpening attempts to compensate for high-frequency contrast loss. For lenses, that loss is described in MTF (Modulation Transfer Function) charts. For cameras, almost all DSLR-size digital sensors — Sigma and Leica are the notable exceptions — have low-pass (anti-aliasing) filters in front of the sensor to intentionally blur the image to prevent moiré. These filters work by reducing contrast at high-frequencies, which means that they reduce sharpness. Display and printing systems also tend to lose contrast at higher frequencies.

General Suggestions

Schewe recommends that sharpness generally be evaluated at a zoom level of 50%, not at 100%. In LightZone, that shows up in the title bar as "(1:2)".

A little trick: if you temporarily set the Sharpen tool's blend mode to "Difference", you can see the edges — and the noise — that the tool will be sharpening. Playing with the Radius and Threshold controls can prove very illuminating. You can play with the Color Selection controls, too, but you may need to click the "enable" check-box (to the right of the Invert check-box) off and back on to get the display to come out right — you shouldn't be seeing significant areas of color. That looks like some kind of bug in LightZone. In Difference mode, the Amount slider just increases the contrast, so you can turn it up to get a better view of the edges.

The 3-step Workflow

Many old-timers say that sharpening should always be the last step in your workflow, but Schewe and Frasier proposed a 3-stage sharpening process, and I'm convinced. Here are some links you might find useful:
http://www.creativepro.com/article/out-of-gamut-thoughts-on-a-sharpening...
http://www.pixelgenius.com/tips/schewe-sharpening.pdf (just the first 5 pages, before it gets into "how to in Photoshop")

Capture Sharpening

Those old-timers will be shaking their heads in disbelief, but with the 3-stage sharpening process, the first sharpening is done right away. In LightZone 3.9, it'll be the first tool you'll add above the Raw Tone Curve for Raw files, or simply the first tool for JPEGs; it might well not be needed for JPEGs. The aim is to somewhat compensate for those high-frequency contrast losses in the lens and the sensor, not to get carried away and make the picture crunchy.

This is typically a whole-image tool (no selection), with a small Radius (1 pixel or so) and a not-too-large Amount. The Threshold setting depends on the noise level of the image. In my (limited) experience, the default settings for the Sharpen tool — 100 at 1.0 pixels with Threshold of 20 — usually work fairly well for Capture sharpening. A more optimum approach is to switch to Difference blend mode, adjust the Threshold as low as possible without picking up any significant amount of noise, adjust the Radius to pick up the desired edges, and perhaps readjust Threshold and Radius until you've got the edges selected but not the noise (as well as possible, anyway). Then switch back to Normal blend mode and adjust the Amount, if necessary, to give some sharpening but not a super-sharp image — you sure don't want any halos.

An alternative here is to use the SLR Sharpen style, which has the default Sharpen tool plus a more aggressive sharpening that uses a Darken blend mode so that there are no white halos. Personally, I think the addition of the "SLR Sharpen Darks" tool is a bit much for the Capture sharpening step, but that's just me. Try it and see what you think.

Creative Sharpening

Creative sharpening is done to specific parts of the image — hair, feathers, other fine detail — as desired. These sharpening tools will almost always have selections of some kind. The Radius setting is usually a bit larger, more around 2 or 3 pixels. The higher the Radius setting, the more powerful the sharpening at a given Amount, so you can play the two controls off against each other. Typically, you'll be doing Creative sharpening in areas with a lot of detail, so noise won't be a factor and Threshold will probably end up at, or near, zero.

If noise is a problem, an alternative to raising the Threshold is to use the Midtone Sharpening style, which doesn't sharpen the shadows and therefore is less likely to sharpen the most noticeable noise. For foliage, there's the MT Green Sharpen style. Of course, you can use other color selections as appropriate to the part of the image you want to sharpen.

Output Sharpening

Output sharpening is what most of the old-timers are thinking about: artificially increasing the high-frequency contrast to compensate for losses that are expected to occur during printing or display. This will indeed be the final step — the top-most tool. You might not even save it in your lzn-jpeg, because this sharpening should be tuned to a specific output device and size.

This is usually a whole-image tool (no selection), with a small Radius (1 pixel or less) and a fairly aggressive (high) Amount value, maybe 200 or more. This is a really good place to use the Difference blend mode to determine the Radius and Threshold, then switch back to Normal blend mode and set the Amount.

If you're outputting for screen usage — Web, email, etc. — then simply adjust to taste. If you're outputting to print, you probably want to be more aggressive, possibly introducing a bit of haloing, depending on the print system. Only experience can guide you there, because you need to guess at what the sharpness loss will be.

tex
Great article, Doug, but I'd like to add a couple of things

First, and I think you'll agree since you alluded to it, there are some differences in AA filters that mean there can't be one sharpening template to cover all cameras(I'm talking raws, here, as jpg's are sharpened in cam). I have had 4 cameras now that I've shot raw with, and they were all different, the biggest difference seeming to be from my Oly E-3 to my Sony A-850 (the Sony seems way softer!). So one needs to tailor this to each camera if it's to be used as a template. Which leads me to think this would be a relatively easy field of endeavor for some future template making.

Second, your article above doesn't deal with the "detail" slider in the Relight Tool. That's another sharpening aid in LZ, first widely touted by Uwe Steinmueller over at Outback Photo. I think I'll contact him about hosting those interesting and very helpful articles he had on his site, now well buried down in his content.

Doug
LPFs

Yeah, absolutely the low-pass (anti-aliasing) filters vary. Canon has a reputation for preferring much heavier filtering than most other DSLR makers, although from what I hear, they're starting to moderate a bit. Nikons are known to occasionally produce color moiré — I don't know about the other marques.

Speaking of Nikon, it seems that Thom Hogan isn't a fan of heavy low-pass filtering.

Leica didn't even put an LPF on the M8 and M9. If moiré happens, they try to fix it in-camera. I suspect this is one of those "tampered Raw" situations. It seems to work well on the M8, but Irwin Puts, arguably the guru of Leica cameras, isn't convinced it works on the M9.

The Foveon sensor in the Sigma cameras doesn't need a low-pass filter to prevent color moiré rainbows, which is what most people worry about. But there's still the chance of ordinary moiré.

The folks at MaxMax will remove LPFs for a (not-so-small) fee, and their site shows both the pluses and minuses.

SFA
Moiré

It's perhaps an odd thing but I don't remember aver coming across a problem with moiré in any shots. I did spot an obvious case from something taken about a month ago. It involved a plant pot and an insect screen door and the result clearly presented some very obvious moiré.

However a quick tweak of the moiré adjustment tool in one of the applications I used fixed it about 95% and, had the shot been more than a snap shot, I'm pretty sure that I could have made that 100% if required.

Now this wold have abeen an 'after the sensor has done its work' situation so may have been a particualrly difficult situation as a 'raw' step and thus justify the filter in the camera. Can't be sire of that though so one wonders whether software PP might be a better longterm solution than a fix using a filter on sensor at the time the image is created.

Grant Perkins

Doug
Relight Detail slider as sharpening

I didn't mention the Detail slider because it's not mainly sharpening and, well, because I'm still not fully knowledgeable about that danged Relight tool... or to be more accurate, the danged Relight tools.

Basically, the Detail and Depth sliders are another Unsharp Mask (USM), intended for use as Local Contrast Enhancement (LCE). The Depth slider is the radius, and the Detail slider is the amount. Being USM, one needs to back off the Detail setting as one increases the Depth; or at least play them against each other.

Speaking specifically of the V5 Relight — the one that you get from clicking the Relight button above the tool stack...

A Detail value of 1.00 is "no effect." If you go below 1.00, local contrast is decreased. As you go above 1.00, local contrast is increased. None of this is directly related to sharpness.

But! There's the Fuzz slider. The Fuzz slider has no effect if Detail is at 1.00. It's definitely a sub-option of the LCE functionality. On the Light Crafts forums, Reto reported doing some investigations and determining that:

Fuzz reveals itself as the radius in a classical sharpening tool, where the radius is 1 at its minimum and 10 or 12 at its maximum (I cannot count the pixels so precisely). The halo produced is fully similar to the halo produced by Sharpening. The halo broadens with higher values of Fuzz; the intensity is defined by Detail - at low values of Detail, say under 2.5, the effect is almost not visible, so it can easily be overseen [overlooked].

It is a bit of a surprise for me to discover here a 'hidden' sharpening tool, considering the artefact's those tools usually create. Sure, it is not very harmful as long as Details is low; the fact that the help [file] makes the user believe he would reduce halos (fuzzing harsh edges) with increased values - quite the contrary of what happens - is problematic.

So, presuming that Reto's correct (and I have no reason to think otherwise), the Detail function is primarily LCE but also includes some conventional sharpening as well.

I'll also note that in the same posting, Reto says this about the LCE functionality of the Detail slider: "My impression that it works smoother than Sharpening for enhancing local contrast is confirmed. This was also observed by Jacek." So it appears to be more than just a simple USM. Or maybe it's just that with the Fuzz added in, it's not necessary to push the Detail slider so high. I don't know.

SFA
Great article Doug and good

Great article Doug and good comments tex.

However ... I haven't read the Fraser/Schewe recommendations although I see where they are coming from and have often thought that early, not too agressive, sharpening should surely be a useful concept to 'tidy up' the pixels into groups prior to further processing. I'm assuming that any noise issues that might appear worse can be dealt with by the Noise suppression feature or some selective work within the early sharpen process.

On the other hand I am coming to the conclusion that even the RAW files from the camera are, in recent times, having sharpening applied to 'suit' the image before being released to the unspecting editor.

Recent developments for in-camera processing power have allowed (as Fabio foresaw iirc) a lot of additional tweaking of images before they hit the memory card. At the jpg level we also see that software is used to correct lens abberations thus making lens manufacturing less costly at the consumer levels - so long as the lenses are consistently manufactured with the same optical aberrations!

Functions with seetting to seek out and correct Chromatic Aberration and it's close relative - Purple Fringing - are become commonly avaliable as are lens corrections for a database of lens/body/focal length/zoom values. These features may be in the editor (Camera manufacturer or third party) or in a plugin. Or, in more an more case, in camera. On application I use quite regularly has a Lens Sharpness slider in with all the len correction stuff availble for procesing RAW files (but no JPGS) and clearly that is an adjustment that would be applied early in the process when converting from the RAW input.

Where no database entry is available for a particular lens is is often possible to have the application do the image assessment and come up wth a profile that can then be saved for future automatic use for the lens or to be applied manually on demand ... thus we can see that the coders are seeking ways to assess the raw data and make recommendations. In may experience they seem to get things right.

Interestingly the application I have in mind obnly has a single sharpening tool level possible at the edit level. The adjustment sliders available are, as far as I can judge, the 3 primary sliders available in LZ's tool. There is no option for indicating where in the tool stack the task is to be perfomed but in all honesty that doesn't seem to matter so I wonder what, exactly, is going on behind the scenes. Mostly curiosity since the results seem perfectly fine!

What I have noticed is that the default settings that are suggested for each image are different, especially radius but often amount too, for images from different cameras. So I suspect that the software is either assessing the files and setting a starting point accordingly or has a database of default values per camera/lens setting or simply has a database of sensor sizes and pixel pitch and uses that.

For example I nave recently been using 4 Canon camera that are all, notionally, 10Mp sensors but of different sizes. (1D3, 400D, G11 and S90). The software seems to mostly suggest different values for each of them although the 1D3 and 400D seem quite similar. (I usually tweak the values up a tad - perhaps I shouldn't!)

Moreover, and something that may be less obvious most of the time, iamges made using certain lenses will 'take' a lot more sharpening adustment than others even though they start out seeming equally sharp optically.

So, what does all that mean (assuming I have observed well enough ...)?

I think I agree with Doug that when using LZ there are benefits for certain images and image types, to perform early sharpening low in the stack. Not too much though unless special effects are intended.

More recently released software applications may be doing this unannounced for newer cameras. It seems inevitable that the manufacturers are doing something in camera anyway these days but not for older cameras of course. Who knows where the individual boundaries are between the 'old' and new cameras .... ? That's anyone's guess I suppose.

I have come to the conclusion that there are no rules here, only guidelines of a rather vague sort on many cases. LZ makes it easy to experiment though and so to discover what works and does not work for different combinations of equipment and software.

As for the future ... that's a free guess for everyone. (Of course it won't matter to us either unless we buy new equipment.)

My thoughts for what they are worth.

Grant Perkins

Doug
Hi Pass Filtering

By one of those laws of perverse nature, right after I started this thread I learned that there is another sharpening tool hidden in LightZone: high pass filtering. I've created a downloadable style template for the tool.

The Hi Pass Filter (HPF) tool seems to be more specific to sharp edges than USM is. Both Schewe and Frasier recommend using edge-oriented sharpening like HPF for the Capture sharpening phase. HPF tends to leave noise alone, which is very important during Capture sharpening. Frasier likes limiting the Capture sharpening to just the midtones, in order to prevent blowing out highlights and shadows — the Midtone blend mode might be appropriate, or you can adjust the color selection à la the Midtone Sharpening style.

Using high-pass filtering in Capture sharpening is logical for counteracting the effects of the low-pass (anti-alias) filters on the sensor. HPF won't really help much with sharpness loss from the lens, but that's a more complicated mess anyway. Since the lens's MTF usually falls off quite a ways toward the edge of the frame, we should at least be looking at an inverted feathered region. I haven't looked into this enough to say anything truly knowledgeable.

Both Schewe and Frasier like USM for the Creative sharpening phase. Interestingly, they both seem to like to oversharpen and then control the sharpening effect with the Opacity slider. I'd think that this approach would be a casting call for halos, but maybe not.

Both Schewe and Frasier like HPF for the Output sharpening phase. Here again Frasier excludes extreme highlights and shadows from the sharpening; he pushes the sharpening well into halo territory ("keeping the haloes to between 1/50th and 1/100th of an inch on the final output") and doesn't want blown-out highlights and shadows. Schewe likes to add a bit of USM sharpening on top of the HPF sharpening, with the HPF doing most of the work.

tex
Doug, let me play the part of dunderhead here...

...and ask how these templates are to be applied to our copies of LZ? I don't see a downloadable link...and if there were one, just download it into the LZ file?

Doug
Downloading templates

Just right-click (or Ctrl-click for single-button Macs) on the link, select "Save link as" and store it into your LightZone Templates directory. On Windows, it's in your Documents folder, under LightZone. There should be all of the "standard" Styles templates already in there.

Depending on your browser, you may need to restore the file name. It should be something like "Classic Tools;Hi Pass Filter.lzt". The part before the semi-colon is the Styles group that it'll appear in, and the part after the semi-colon is the name that it'll have within the Styles group.

Then to apply it, just click it in your Styles palette.

Gabe
I'm having trouble getting

I'm having trouble getting this to work. The download works and it appears as a style with the right name but when I click it I get:

Couldn't access Template "Classic Tools;Hi Pass Filter" in C:\Users\stevegabeler\Documents\LightZone\Templates: Couldn't read XML: org.xml.sax.SAXParseException: Attribute name "data-pjax-transient" associated with an element type "link" must be followed by the ' = ' character.

I'm running on Windows 7 64 bit

Gabe
I gave up on this for a while

I gave up on this for a while and recently went back, looked at this and other templates and found that the download was converted into something else (HTML?). I followed the link to the GitHub page, copied the text, pasted it into notepad, saved it to the right filename and it works! There were some hints along the way that Thunderbird interperets *.lzt as something else(?)

kvv
Thanks for the exhumation of the legacy tools! :)

Have just tried HPF and it seems to be superior to USM (despite I used to use 2 USM instances - darken and lighten ones - with color/tone customizations). In particular, thin twigs are rendered much better, and blue sky behind has no noise even without inverting the blue color mask. :)
I do not understand the logic of moving the radius to the left and to the right from 0.7. There is visible difference, but what is the idea behind?

Doug
Radius on Hi Pass Filter

The Radius value is used to determine how sharp an edge has to be in order to be noticed. (That's a simplified explanation.)

If you make Radius fairly small, then only the sharpest edges are picked up. If you make Radius fairly large, then only large differences in brightness between two fairly large areas are picked up.

Roughly speaking:

  • Below Radius=0.2, HPF won't pick up anything because the sensor array can't distinguish edges that small.
  • At Radius=0.7, HPF will pick up the most detail (and noise).
  • Above Radius=1.0, HPF won't pick up much detail.
  • Above Radius=1.2, HPF will tend to blur rather than to sharpen. In some cases, speckles may appear. Radius values above 1.2 probably aren't very useful.

The most useful range is between about 0.5 and 0.9. You can see the edge-selection effects of Radius by temporarily setting the Blending Mode to Difference. At the lower and higher Radius settings, you may need to turn Gain up to help see.

I've personally settled on Radius=0.6 as my usual setting. Also, to prevent overshooting, I usually use the Midtones Blending Mode.

kvv
HPF details

Thanks for the clarification. I still have questions though.
Let's take a real life example. A black twig and blue skies behind. And an HPF instance in Lighten mode.

If I set radius below 0.7, I have fairly thin white edges (halos) at the twig borders. If I set radius above 0.7, the white edges are quite wide (regardless the gain value). But if I pick up larger gain values for smaller radiuses and vice versa, both parameter pairs end up with approximately equal image (on condition that I do not go too far from radius 0.7 to either direction).

This being said, what is the twig edge? It is a 2 pixel wide straight long black line, that's it. So what is the exact meaning of the "edge width" here (as a function of the radius value)? We have a fixed structure here (with exact values of edges - regardless measurement units), but the response for different radius values is different. So I would accept the "edge width" idea if the tool response for the twig was observable just for a concrete radius value (that would match some edge value associated with the twig). But the tool response is much more complex than that.

Doug
More on Hi Pass Filter

There's no easy answer, which is why I'd used terms like "simplified explanation" and "roughly speaking". :-)

First off, I don't know exactly what LightZone is doing. But in general, a high-pass filter involves what's called a convolution of the image data. Again, roughly speaking, that operation replaces a pixel with a weighted average of the pixel and some of its neighboring pixels. The "magic" is in the choice of the weighting, which is mathematically determined in a way that achieves high-pass filtering: to emphasize changes that occur within a small area.

The radius will typically determine what's called the kernel for the convolution, which (again, roughly speaking) is the collection of neighboring pixels that will be taken into account. The larger the radius, the more pixels that get included in the kernel. The radius also affects the computation of the weighting factors.

We're pretty much stuck with just trying things and seeing what happens, rather than trying to reason it out. At least, beyond a certain rudimentary understanding.

kvv
high pass filter rules

Can't say that my non-rudimentary understanding of the tool has been improved, but the results are truly amazing. :)

Thank you once again for discovering this somewhere in the guts of lightzone. It really helps to save noisy images.

SFA
HPF

Doug,

I joined the LZ party a few months before V3 was release. Started with 2.3 or 2.4 iirc. I don't recall ever seeing HPF as an option but may have missed it. Is it really part of the early versions legacies retained mainly for backwards compatibility with old edits?

HPF is a well used concept of course. I wonder if the basic functionality was further refined and included, in concept, in another tool? Did it end up as part of Relight?

Grant Perkins

ETA: Actually, thinking about things a little more, if Relight includes an HPF function then a RAW process stack that starts with an extra Noise Reduction tool (if the RAW tool is not adequate) and then a Relight tool (which has long been the suggestion for the first tool in the stack), then HPF will in effect become the Capture Sharpening step of the worlflow you outline above.

Doug
Hi Pass Filter provenance

I have no idea when the Hi Pass Filter was put in or removed from view. I just stumbled across it, and it seemed to work pretty well at first glance. It could be that at one time it was labelled "Sharpen", and was later replaced with the current USM tool, like the Polarizer was once labelled "Relight" but got replaced.

I don't have any archeological information on LightZone, so I'm clueless.

SFA
Hi Doug,

Hi Doug,

I was just wondering if you discovered any 'notes' wherever you found the HPF stuff. Obviously not. I wonder if any of the really old timers can shed light on it?

You have to love software with inbuilt legacy stubs. ;)

otalp
Just for the files: the HPF

Just for the files: the HPF template works well with my LZ 2.4 (8224) Linux version.

Best,
Alf