How to recursively sharpen using Rawtherapee?

Well now, that looks to be the reason I asked. I hadn’t noticed it also being present on the “Tranform Tab”. Maybe it is worth verifying that this could be the only operation performed using that tab. In that, can Post Re-size Sharpen be done even when no resizing is done? If so, sounds like the answer is that RT can sharpen exactly twice using Unsharp Mask. This is good to know. Thanks!

I’ve never head of recursive sharpening, and I don’t know what that might be.

On the other hand, iterative sharpening (sharpening once, then sharpening again) has an obvious explanation.

One school of thought for digital photography is that a small sharpening should be applied first to compensate for the AA filter etc, then apply dodging/burning/etc as desired, and finally resize and sharpen (perhaps as a single operation). That seems plausible.

But sharpening with radius r1 followed by sharpening with radius r2 is not at all the same thing as sharpening with radius (r1+r2).

1 Like

I am not a programmer, so I had to look up what the two meant. I found a statement here:

In simple terms, an iterative function is one that loops to repeat some part of the code, and a recursive function is one that calls itself again to repeat the code.

@snibgo shares two cases.
1 Sharpening post interpolation.
2 Sharpening, then repeating it, with or without variation.

Papers seem to indicate that (2) is deleterious to image quality. My impression regarding the repeat of filters is to save time and computing power.

@ajax The article you quoted in your first link says

Radius: determines how wide an area at the transition is affected. 
Try increasing the Radius to 4 and 8, and you’ll see that area that is
modified at the transition widens.

That’s nonsense.
Gaussian blur is a function which calculates a new value for a pixel from the old value of the pixel and the values of surrounding pixels like

newval(x,y) = gauss(oldval(x,y), radius)

The radius determines the size of the surrounding area which will be used to calculate the new value for the pixel. It does not determine the size of the area which will be influenced by the gaussian blur.

You can apply gaussian blur to one pixel out of 10000000 without an effect to the other 9999999 pixels.

I’d say that, as long as the two tools (resize and post-resize sharpening) are active, then they’ll be used in the processing pipeline. However, I haven’t tried myself – I almost always resize my processed images.

@ajax I’m currently working on improving the sharpening tools (USM and RL) in RT.
Maybe worth to follow an issue on github in case you want to sharpen for fine details.
The issue is not only about the Microcontrast tool. It’s also about USM and RL-Sharpening in RT

That’s what ‘RL deconvolution’ in RT does (Richardson-Lucy) :wink:

1 Like

Oh I didn’t know that! Consider me educated :smile:

1 Like

I agree, but I will take a look whether a resize from (width1, height1) to (width2, height2) where width1 = width2 and height1 = height2 (which simply keeps the dimensions of the image) is done without effect to the resulting image. If that’s not the case I will change it.

1 Like

I’ve seen a lot of creative license in the use of other disciplines’ terminology in photography - ‘recursive sharpening’ would be one.

Recursion is a special form of iteration in algorithms, where the function being performed is called within the function itself. A special form of ‘self-eating watermelon…’

I think what you might be reading about would more properly be called ‘iterative sharpening’, the theory being one application of size 10 sharpening is less ‘nice’ to the image than ten successive size 1 applications. Somewhere (maybe here, don’t remember) I read about doing downsize resizing as two operations, the first one gets you about 2/3 there, the second one gets you to the target size, and the result is supposed to be as clean as a single operation followed by a sharpen. Same thinking…

The three applications of sharpening discussed above are about three separate sharpens done in specific places of the workflow for different purposes. I wouldn’t think of them as ‘iterative’.

If you want to mess with real iterative sharpening, my rawproc tool will let you stack up as many sharpen operations as memory will allow. I only implement USM, but you can easily compare one application of #10 to ten applications of #1

Resize to same size currently does nothing. Means, post-resize-sharpening is not called in this case.

I think it’s an interesting question whether it should or not (I think it should apply the second round of sharpening as long as the tool is activated by the user). Please let me know if you’d like to me open an issue.

I agree that it should call pr-sharpening in this case.

1 Like

No need to do that. I’m already working on a fix :wink:

1 Like

Live support. :+1:

2 Likes

While I don’t think this objection to the referenced article is related to my inquiry I do get your point. As it happens I came across that article by reading this article in Wikipedia. It is one of the only “External Links” that still works. Wikipedia is widely used and I think you are much better positioned than me to undertake correction of the problem for Wikipedia.

As it turns out, I did also perform the test case being described in the article and it seemed to re-enforce the point the author was making. There is reason to believe that I’m not the only one subjected to this misinformation.

Oh my! It looks like I am guilty of some carelessness when it comes to choice of terminology. I certainly was not trying to invent any new concepts when it comes to sharpening. After reviewing the excellent lesson provided herein regarding the terms “recursive” and “iteration” I’m inclined to think that I meant neither. I was simple trying to ask how a user of RT could request to have the “Unsharp Mask” applied multiple times. Possibly the word “repeatedly” would have been a better choice than “recursively”. Sorry about that but I am grateful for the lesson.

1 Like

The Wikipedia article is reasonable, although I wouldn’t distinguish artificially between “sharpness” and “local contrast enhancement”. I would say it always increases local contrast, and “local” is determined by the radius and “amount” determines how much the contrast is increased.

If we repeat a USM at a certain radius, the overall effect is roughly the same as one USM at the same radius but an increased amount. This is quite different to a USM at a larger radius, because the definition of “local” is different.

As with many operations, the concepts are not easy to explain. It’s best to play with images and see what happens.

I show an image subjected to USM in different ways. The four numbers are ImageMagick parameters: radius (0 means auto-calculated), sigma, gain (ie “amount”) and threshold.



Doing a USM twice:

Doing a USM once, with a larger gain (amount):

(If some images shrink on your computer, right-click to see them full size, or download them, or something.)

We can see that doing a USM twice is closer to one USM with a larger gain, than it is to one USM at a larger radius.

2 Likes

I might add:

  1. Negative amounts will extrapolate from the original past the blur. This is not often useful.

  2. Amounts greater than one are possible, to exaggerate the effect.

  3. In the above post, I have used large radii and amounts to make the effects obvious. We often want more subtle effects.

  4. Are two consecutive USMs ever useful, or can we always make the same effect with a single USM? I think they can be useful. For example, a heavy amount with a small radius, followed by a small amount of a large radius:

magick toes.png -unsharp 0x1+1+0 -unsharp 0x5+0.2+0 usm_u6.jpg


I don’t think the same effect can be obtained from a single USM.

Ah, I thought you were quoting something you had read. No worries, the discussion we’ve had surrounding it has been interesting.