Enhanced Unsharp Mask in PhotoFlow - please test!

@Silvio_Grosso
To access the new enhanced USM you have to:

  1. click on the red icon at the left of the layers list
    47%20PM
  2. go to the “detail” tab and select the “sharpen” tool
  3. in the sharpen tool, select the “enhanced unsharp mask” method
    36%20PM

I have noticed that the default amount value is far too strong, you have to manually dial the slider down to 200 or 300 for a good result… I will fix this ASAP

@gadolf my edge sharpening preset is surely better in preserving the noise, but the drawback is that the transition between sharpened and non-sharpened areas is much faster, at the point that it is noticeable and sometimes not very pleasing. That’s why I have been looking for a better and more elegant solution…

1 Like

Hello @Carmelo_DrRaw

Thanks a lot.
I have just deleted my last post because in the end I did find this new tool :slight_smile:

@Silvio_Grosso I suggest to keep the radius small, as you would do with s standard unsharp mask. The idea is to obtain a result similar to USM, but better.

@anon41087856 in fact, I apply the guided filter to a log10 RGB luminance channel, and then I convert back to linear RGB luminance before computing the differences.

I found that a factor of 4 between the two thresholds (applied to log10 values) gives a reasonable starting point, with 0.005 and 0.02 as absolute values.

I read the op and thought to myself, Wasn’t this posted a while back? Then I realized that my bad memory equated @Carmelo_DrRaw work with some of the papers I read. I don’t have time to find them again but there are several that address thresholds.

Hello @Carmelo_DrRaw

I have been testing this new option and indeed it does look like it doesn’t increase the overall noise :slight_smile:
With the above image (head of a dragonfly) I have just crashed the application while increasing the radius.

EDIT: just tried to reproduce this crash to no avail.
Now the radius change does NOT produce any crash (Windows 10; Intel I7, 8 gb RAM).
Once in a while, there are artifacts (namely gray “squares”, like tiles, stamped on the 1:1 preview of image) but it suffices to move a little more the sliders to remove them.
Here they are:

1 Like

The one from this play raw? Sun and Thunder in Geneva - #20 by kakashy

1 Like

Hello @Carmelo_DrRaw

Just tried to crash once more Photoflow and It is extremely easy on my Windows 10 - 64 bit computer to reproduce now.
I suppose it is some huge memory leaks…
BTW, I have got an Intel I7 cpu and 8 gb of Ram.

To reproduce the crash it suffices to open a very big image.
I have tried with a 61 Mb Tiff.
You open the Tiff and you change the radius and instantly Photoflow always crashes.

Here is the error got on the cmd prompt:

(photoflow.exe:55044): GLib-GObject-CRITICAL **: 23:39:15.038: g_signal_handler_is_connected: assertion ‘G_TYPE_CHECK_INSTANCE (instance)’ failed

(photoflow.exe:55044): GLib-GObject-CRITICAL **: 23:39:15.054: g_object_unref: assertion ‘G_IS_OBJECT (object)’ failed

(photoflow.exe:55044): GLib-GObject-WARNING **: 23:39:15.054: instance of invalid non-instantiatable type ‘’

(photoflow.exe:55044): GLib-GObject-CRITICAL **: 23:39:15.054: g_signal_handler_is_connected: assertion ‘G_TYPE_CHECK_INSTANCE (instance)’ failed

(photoflow.exe:55044): GLib-GObject-CRITICAL **: 23:39:15.054: g_object_unref: assertion ‘G_IS_OBJECT (object)’ failed

(photoflow.exe:55044): GLib-GObject-WARNING **: 23:39:15.054: invalid uninstantiatable type ‘’ in cast to ‘GObject’
!!! Pipeline::set_image(): wrong ref_count for node #1, image=0xafa0970

(photoflow.exe:55044): GLib-GObject-WARNING : 23:39:15.070: invalid uninstantiatable type ‘’ in cast to ‘GObject’
**
ERROR:/sources/src/base/pipeline.cc:287:void PF::Pipeline::set_blended(VipsImage
, unsigned int): assertion failed: (G_OBJECT( nodes[id]->blended )->ref_count > 0)
Bail out! ERROR:/sources/src/base/pipeline.cc:287:void PF::Pipeline::set_blended(VipsImage
, unsigned int): assertion failed: (G_OBJECT( nodes[id]->blended )->ref_count > 0)
Exception code=0x80000003 flags=0x0 at 0x00007FFD304F0192

Thanks, I will try to reproduce this…

Here is a first attempt and the corresponding settings:


08%20AM

Just merged your idea in my code (working in linear RGB), but I find the high-pass cut-off too harsh and a bit unnatural. I want it to degrade more gracefully, so I modified the equation to:

USM(I) = I + \alpha \cdot \left((I - GF_{TL}(I) )- \frac{(I - GF_{TH}(I)}{2}\right).

In my UI, I let the user setup the GF threshold in dB for a more even feeling (between 0 and -4 dB). The high cut-off is therefore set -1.5 dB from the low cut-off.

Here is what I get in an iterative setup varying the GF window from 3 px to 13 px (every denoising disabled):

EDIT: the full output of image doctor, with an iterative joint deblurring and denoising modified with this method:

@heckflosse has recently done a lot of work on capture sharpening, which is intended to be applied very early in the pipeline, just after demosaicing. However, the sharpening tools currently available in photoflow are mostly intended to be applied at the end of the processing. Sharpening after resizing is another option that I have not yet explored in detail.

Another suggestion I have is to apply crop/rations after the basic adjustments, because by doing this you apply the layer masks to the original image, and they are thus independent of the geometry manipulations you do later. Same goes for the perspective corrections. Apply all geometry corrections just before sharpening.

@Silvio_Grosso When to do sharpening depends on the image contents and what your aim is in postprocessing.

I am of the opinion to sharpen a little after (sometimes before) softness is introduced; e.g., raw from camera, demosaicing, denoising, smoothing or resizing. The rule of thumb is to avoid artifact-causing or aggressive sharpening until the end, and only sharpen (such as capture sharpening) if you know what you are doing. Proper sharpening at the beginning can go a long way, if and only if you do it properly and smartly.

If you examine my PlayRaws, they are usually clean, unless I am doing something experimental, which I suppose is quite common. For serious processing, I tend to favour a little soft over an artifact ridden image, no matter how slight.

Here a screenshot from RT using Capture Sharpening:

Same + USM

I would go so far as saying that there is no sharpening, there is only deblurring. Blur happens:

  • when interpolating/upsampling the raw file to reconstruct an RGB signal from a CFA (demosaicing)
  • when bending light rays through glass lenses
  • when transmitting light rays through smoke, dust, fog, windows, etc.

So the place where you deblur depends on the type of blur you want to revert. And basically, in signal reconstruction, you need to revert digitally the bad effects in the opposite order they are applied in real life.

Over these past 2 years, I have acquired the belief that deblurring, denoising and defringing should be performed in a joint fashion. They all are 3 aspects of the same problem : spatial decorrelation between channels and inside channels themselves.

Definitely: on a technical and fingers-crossed level we are trying to restore the image, not sharpen it per se.

Same here in dt image doctor:

1 Like

@heckflosse I have taken the .pp3 from your PlayRAW contribution, and used it as a starting point for a direct comparison.

This is the RT processing without capture sharpening:

Then RT + capture sharpening

Finally my enhanced USM with settings that give a more or less similar amount of sharpening:

22%20PM

@anon41087856 in your DT implementation, what is exactly the input of the guided filter?

The bug should be fixed now, could you test the latest package from today?

Thanks!

RGB coming straight from the demosaicing module.

Hello @Carmelo_DrRaw

Just tested again on:

  • Windows 10 (64 bit);
  • CPU Intel I7;
  • RAM 8gb

Now, the crash regarding the Enhanced Unsharp Mask with BIG tiff images (70-80 Mb) is gone.
Everything works as expected.
I have tried also the zooming in-out and panning tools and all works fine :slight_smile:
Congratulations for fixing it!

I had some spare time and I have worked with this version for around 2 hours straight.
With Raw file pertaining to my Nikon D700 camera (around 9-10 Mb each) everything works extremely well: no complain whatsoever…

On the contrary with big TIFF files (70-80 Mb each) there are some operations which behave oddly.
I suppose Photoflow is not optimized to work smoothly with such big files on Windows 10 (yes, I do know you only have Mac and Linux to test it…) and trust me, this is not a criticism at all!

For example:

  • sometimes the crop tool is not applied to the image;
  • once in a while, very rarely tiles appear on the image (this is a very minor disturbance…) when sharpening;
  • Most importantly, Photoflow usually freezes when you save your tiff change as jpeg (“Export current image to raster format”).
    There are no particular information on the Cmd prompt and in the end, I usually shut down the Photoflow.exe through the Windows Task manager (CTR+ALT+DELETE shortcut).

I have recorded a short video (1:47 minutes; 2,5 Mb) with this crash when you save the TIFF as jpeg. There is also the oddity concerning the crop tool not applied to the TIFF image [1].
As anticipated, these bugs only occur with big TIFF images. With my NEF RAW files everything works fine (crop tool working; export to jpeg executed etc).

BTW, my monitor is extremely small (Asus notebook; 13 inch) and it is NOT the best one to test your GUIs. Bear with me :slight_smile:

[1] Dropbox - File Deleted