Enhanced Unsharp Mask in PhotoFlow - please test!

Yes, this IS a bug… will look into it.

Nice! and thanks for suggesting the approach.

Better looking at it, I noticed a thin halo (probably not visible in the screenshot):

Hello @Carmelo_DrRaw

Just tried the new algorithm on Windows 10 (photoflow-w64-20191102_2121-git-enhanced-usm-ce38236b53b4fc8490ea1d3d74daeb86bea50d7b).
Overall it works great as far as the noise is concerned.

As regards the haloes around the sharp edges I don’t understand how I can reduce them.
I have tried to keep the “threshold low” slider at the maximum amount but they are still present.
I suppose you can not entirely avoid them, right?

Here is an example (NEF - Nikon D700).
Take a look at the lizard “fingernails”:

BTW, greetings from Turin. I am happy you have lived in the same city in the past :slight_smile:

I noticed that the halo is reduced if the sharpening goes after the raw developer layer.
But then dark edges seem to get stronger (look at the bridge pillars in the background)



I did some comparison between your edit and my new code, to see the differences in sharpness.
Left is my version with radius=1, amount=400, threshold_low=10 and threshold_high=50. The input image is the RT output without sharpening.
Right is your RT version (I have used a build from the current RT dev branch).

My feeling is that your sharpening produces crisper details, on the other hand my version, while slightly softer, has smoother transitions between sharpened and non-sharpened areas.
All-in-all this is only visible when pixel-peeping at 1:1 or more, while already at 1:2 the two versions are practically undistinguishable…

Could you post the pfi file? This image seems to provide a good test case for checking the halo reduction mechanism.

Sure, here it goes.
IMG_6061.pfi (31.5 KB)

As a RT user I have to say that despite loving the new sharpening methods in RT I think the main downside is the grainy transition between sharpened and unsharpened areas. In the example above it’s barely visible but can occasionally come out stronger. I think the vulnerable scenario is transition zones between in and out of focus. ping @heckflosse

To my eyes the RT version above is a fair bit sharper without affecting the noise.

1 Like

Do you observe that only when using a dual-demosaicker or also when using plain amaze/rcd?
Btw: capture sharpening works best with rcd or pixelshift. When using amaze it often sharpens the amaze diagonals too much.

1 Like

I tend to use dual-demosaic all the time now. I did start looking into whether it was the dual-demsaick :wink: (like that word better) that was the issue but got interrupted before forming a conclusion. Will do some experimentation when I find the time, perhaps I can find a good example image.

1 Like

It’s about time to make a speedup for vng4…


Looking forward to it.

Looking at the backlogs it’s already 10 times faster than 4 years ago:

But I will see what I can do to further improve it…

I’ve done some quick tests of capture sharpen oof “dither” now. Is this the place to upload or should i start a thread in the RT forum?

edit: may as well link to filebin from this post https://filebin.net/nofwa4edaqoreb80
Look at the transition from petal to white background above the central diagonal stem. Album view works well in filebin.

Imho better to post in the RT forum

1 Like

This part of the experiment continued here Capture sharpen, soft edges test

I did some further work to improve the halo suppression, as well as the transition between the sharpened areas and those where the noise gets protected.
I have also renamed the sliders as “noise threshold” and “edge threshold” to make their role more clear.

Here is what I can achieve on your image with the latest version:

Now coming to the meaning of the threshold sliders, I will try to give a simple visual explanation using an image with a double gradient:

In the middle there is a sharp edge that increases in amplitude from left to right.
Setting the noise threshold to 0 and the edge threshold to the maximum, the edge gets sharpened all the way to the right:

Lowering the edge threshold, the right part of the edge starts to be preserved, and only the “not too pronounced” part of the edge gets sharpened:

Notice that the edge is still sharpened all the way to the left side, proportionally to the initial step amplitude.

Now, if one rises the “noise threshold” slider from 0 to 10, the sharpening in the left part of the image gets suppressed. That is, small variations in intensity (like those due to noise) are “protected” from sharpening:

Moving the threshold slider up to 50 extends the “preserved” region to the right:

The effect is rather subtle, which also means that one has a lot of fine control over the noise/texture sharpening tradeoff. There is also no sharp transition between the two, so the result should look quite natural.

Hope this clarifies a bit more how to actually use the sliders with this new tool…

I have implemented one more improvement to the new USM algorithm.

Some of you might know about the “octave sharpening” method, which consists in blending several sharpened versions of the original image, at increasingly higher radius and lower opacity. This adds some “volume” to the image in addition to the enhancement of the small details.

In the new tool, this is controlled by the “number of scales” parameter.
For example, for a radius of 1 and 3 scales, the contributions to the sharpening are as follows:

  • 50% at radius=1
  • 25% at radius=2
  • 25% at radius=4

Here is a simple sharpening with radius=1 and one scale:

Same image with radius=4 and one scale:

Finally, radius=1 and 3 scales:

Again, your feedback is very much appreciated!

1 Like

I started by trying to eliminate the halos. In your setting above, I can still see them. I could eliminate them by lowering the edge threshold to 6.3.
But a so lower threshold seems to reduce the effect of the other sliders.
I then tried to tweak the new # of scales, and all it seems to produce is a smoothing effect.
Without sharpening:

Before raising the # of scales:


Anyway, at least for this particular image, I’m satisfied with the result.

EDIT: Scrolling thru the screenshots, I noticed that raising # of scales added some local contrast to the water, which is nice.
EDIT2: I haven’t noticed the show mask feature before. That is good! However, having it enabled, raising # of scales from 1 to something much higher (~6), gives this while processing (when it finishes, the mask gets back)

1 Like

The guided filter generates a variance-dependent blending between the original and the blurred images. The higher the variance is locally, the lower is the weight of the blurred image. However, such weight is never 0, so some degree of blurring (and therefore of halos) is always present. This gets accentuated when the number of scales is increased, because of the contribution of blurs at larger radii. For example, with radius=3 and 6 scales one gets contributions (with decreasing strength) from radii of 3, 6, 12, 24, , 48 and 96 pixels!

yes, because almost all transitions are considered “edges” and therefore not blurred by the underlying guided filter.

Yes, because of the contribution of larger radii that adds some “local contrast” to larger-scale variations on top of the sharpening of small textures.

With 1 scale, all the sharpening comes from the blur at the base radius (3 pixels in your example). When you increase the number of scales, contributions at larger radii are introduced that “replace” the one at 3 pixels, so sharpening of small textures is decreased…

Personally I would suggest to start with a base radius of 1 and 3 scales, at least if the goal is to sharpen fine details. I will also tweak a bit the relative strength of the scale contributions, lowering the weight of larger radii.

I will check what is going on, although I consider the “show mask” feature mostly a temporary diagnostic tool while developing the filter.