Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.9k stars 323 forks source link

Document Capture Sharpening #5453

Closed Beep6581 closed 4 years ago

Beep6581 commented 5 years ago

Document Capture Sharpening #5412

heckflosse commented 4 years ago

I am not good at documenting. Nevertheless here some informations about Capture Sharpening

Advantages of Capture Sharpening over (normal) RL-deconvolution in RT

1) CS is applied very early in the processing on linear data directly after demosaic to minimize halos

2) CS features automatic contrast threshold calculation

3) CS feature automatic radius calculation

4) CS features automatic iteration limitation

5) CS features corner boost

6) CS features viewing the contrast mask at all zoom levels, even in navigator

7) CS can be combined with the other (USM/RL) sharpening methods in RT, though the only useful combination is CS + USM with a small radius

Disadvantages of Capture Sharpening over (old) RL-deconvolution in RT

1) CS works only on raw files

2) CS doesn't work well with Lensfun/LCP CA-correction because CS is called before CA-Correction. No problem with raw CA-correction

Requirements for good CS

1) For images with sharp transitions between clipped highlights and non-clipped areas the white level needs to be correct to avoid halos

TechXavAL commented 4 years ago

This is a quick mockup of a possible documentation for the tool. It needs polishing, but I'm sure Morgan will be much better than me doing that.

Needless to say, but modify it as you wish:

«START OF DOCUMENTATION» What it is

The Capture Sharpening tool is meant to recover the details lost or blurred by diffraction, or some other kind of Gaussian type blur. It is applied just after demosaicing the raw data, and thus it only works with raw images. On top of that, by working right after demosaicing, the tool modifies data in a linear gamma, and that helps preventing halos.

Even though you can get awesome results with the default settings, bear in mind that this tool is not meant to become the definitive and only sharpening tool to be used. It's better looking at it as a necessary step so other tools get an image with better distinction between noise and details. In this sense, it can be combined with other sharpening methods, but most probably the only useful combination would be with the Unsharp Mask tool, set with a small radius.

How it works (settings)

Contrast Threshold

The tool, analyzes the image and calculates a threshold to prevent sharpening noise. You can leave the automatic Contrast Threshold calculation on, or you can turn it off and set it to your liking. The higher the number, the higher the contrast a detail needs to have to get sharpened, and at the same time the less noise will be sharpened (because noise has a tendency to have lower contrast).

Radius

When an image gets blurred by diffraction, a single pixel spreads into the neighbouring pixels, with an amplitude or radius that gets bigger the more it is blurred (https://www.cambridgeincolour.com/tutorials/diffraction-photography.htm). The purpose of this tool is to reduce blurring, so by default it tries to guess which is the radius needed to counteract the diffraction blur.

You can always choose the radius you want, but an improper setting will lead to haloing on edges. Remember you're trying to undo the blurring that happened with the camera-lens combination.

Even though the radius calculated by default is spot on most of the time, there are scenarios where the images are going to be processed in other programs (like in focus stacking, astronomical images, super-resolution images, ...) where you may need to be extra picky with noise and oversharpening. In those scenarios it's better that you turn off the auto-calculation of the radius and set a lower value, judging only by looking at the preview area. You will end up with less sharpening, but you won't introduce artifacts that most probably will be enhanced by the next software used.

Corner Radius Boost

As it isn't uncommon that the amount of blurring is different in the outer areas of the image than in the center, the tool allows you to increase or decrease the radius used on such areas.

If you turn the slider to the right, the sharpening in the outer areas will be stronger, while sliding to the left will lower the sharpening applied.

Iterations

Once it knows those radii, it performs a series of calculations to get to a sharpened image, closer to the original subject. And it does the same process over and over through the iterations set, to reach its goal. Given that too many iterations will lead to artifacts, the tool can be set to limit automatically the number of iterations applied.

While adjusting all the settings, you can always turn on and off the Sharpening Contrast Mask, to easily see the areas that will be sharpened (colored white), against the areas that won't (colored black). And you will see the mask both in the Preview area and in the Navigator panel.

Prerequisites

If you expect to get the better enhancement in your images, specially on images with sharp transitions between clipped highlights and non-clipped areas, the camera white level needs to be correct to avoid halos. That often means going to http://rawpedia.rawtherapee.com/Adding_Support_for_New_Raw_Formats and after reading it, sending several pictures to the developers, so they can set into the program the correct sensor white levels for your camera model. «END OF DOCUMENTATION»

heckflosse commented 4 years ago

Some additional things we could mention in documentation.

1) The auto calculation of cs radius on long exposure raw files (having hot pixels) works much better after raw hot pixel filter (example file: http://rawtherapee.com/shared/test_images/renon_earth_pyramids.pef without hot pixel filter auto radius is calculated as 0.52, with hot pixel filter it's calculated as 0.81)

2) cs is applied on the full image which has some downsides and some upsides 2.1) downsides: being applied on the full image it needs some processing time 2.2) upsides: being applied on the full image it needs the processing time only once (if parameters are not changed, here the auto-calculations helps a lot) and so gives faster panning experience at >= 100 % view. I also gives a sharper preview at less than 100% preview and allows viewing the sharpening mask for the whole image.

TechXavAL commented 4 years ago

in point 1, from a user perspective it's better saying:

«The auto calculation of cs radius with raw files having hot pixels works much better with the Hot pixel filter turned on (located in the Raw tab)»

(a plain user doesn't know which tool comes first, but do know which tools are turned on).

About the point 2, I would include it as a third paragraph of the «What it is» section:

«START OF THIRD PARAGRAPH» Moreover, being a tool that is applied on the full image, you will notice that it takes time to process every change made in the settings, but on the other side if you don't change anything, you will be able to quickly pan the image and will get a sharper preview of the enhancements. «END OF THIRD PARAGRAPH»

fferreres commented 4 years ago

I am using the nightly build. While RL and CS do something similar, it does a lot of sense to use it in combination with RL. Because of the much lower noise, CS works a lot better that low thresholds eg. 7, and will produce a result that RL can further improve at the small frequencies such as 0.60 radius 20 threshold, and both tools low in iterations (20~30).

Example 1 (Combined): https://2.img-dpreview.com/files/p/E~forums/63444480/f9b5b07aec574bd9954249e7d07e080e

Example 2 (CS): https://2.img-dpreview.com/files/p/E~forums/63444480/d81f23161c0b4e8195c0595a49a3aca3 (CS+RL): https://2.img-dpreview.com/files/p/E~forums/63444480/b8399289ee6c4560a07d55c5af8c7d8b

TechXavAL commented 4 years ago

Well, most probably the combination of several sharpening tools will depend on what you're trying to get, and which are you limits regarding the amount of artifacts shown.

I am currently using quite a lot a combination of CS and RL, but not exactly as you suggested: I start by tweaking CS to get the better results with the least artifacts (to my taste), and after fully processing the image, I end up sharpening with RL, but with a pretty high Threshold (60-100) and a radius that gives the least possible halos. The amount is usually high (90-100).

That way I can give a final sharpening to the most important edges and details, giving them crispness, and leaving completely untouched noise and areas with low contrast.

I'm just waiting the moment that RL will work with linear data, just like CS. The sooner, the better.

Anyway, I'm not sure so many options and combinations should be added to the documentation, as probably that will lead newbies to confusion.

heckflosse commented 4 years ago

@TechXavAL

I'm just waiting the moment that RL will work with linear data, just like CS. The sooner, the better.

Should be not difficult to implement. But keep in mind, that RL still will be at the very end of the pipeline, means any non linear change (e.g. strange curves or whatever) may again produce artifacts in RL

TechXavAL commented 4 years ago

@heckflosse

may again produce artifacts in RL

I'm aware of this. But the idea is not that we will leave in an ideal world, but to make us the most comfortable as possible in our real world... :smile:

Meaning that at least it will probably introduce less evident artifacts, if we proceed with caution...

As a side note, this has something to do with a long thread in pixls.us, where I posted my concerns about the linear pipeline. If the pipeline and the tools work that way, then there shouldn't be problems with non linear changes. But I think that must be discussed somewhere else.

heckflosse commented 4 years ago

To document capture sharpening we need some good example files. Here's one from me: https://rawtherapee.com/shared/test_images/irish_coast.nef

Screenshot from above raw: grafik

Feel free to provide your files too.

heckflosse commented 4 years ago

Another candidate to document capture sharpening https://rawtherapee.com/shared/test_images/clematis_vitalba.nef grafik

TechXavAL commented 4 years ago

I assume those are comparisons at 1:1

I think they are perfectly suitable for the task. But one thing that could be done with one of them is forcing the parameters to show the problems that may arise with a bad radius, as explained in the radius section. A good image for this would be the close-up (maybe 3 comparison images: left good radius, center no CS, and right bad radius).

And another bad result must be compared when using an image with good white level against the same shot, the same CS parameters, but not good white level.

Sadly, I don't have the time right now to do that.

heckflosse commented 4 years ago

I assume those are comparisons at 1:1

Yes, those are 1:1

But one thing that could be done with one of them is forcing the parameters to show the problems that may arise with a bad radius

Good idea :+1: I will prepare an example. Should not be difficult

And another bad result must be compared when using an image with good white level against the same shot, the same CS parameters, but not good white level.

Another good idea though it turns out to be more difficult to run into this case after the limit iterations. Will take a while to find a good example.

michaelezra commented 4 years ago

This is a great feature. I compared this to Topaz Sharpen AI (using the 'Sharpen' method - no defocusing or motion blur correction) by sharpening the before images from the screenshots above and RT's result is absolutely solid - basically the same and in some areas more detailed!

TechXavAL commented 4 years ago

I'm not sure about this, but I think this issue can be closed, as the documentation is already online at RawPedia

heckflosse commented 4 years ago

@TechXavAL Agreed. Thanks for your work on this :+1: :+1: :+1: