Tuesday, February 17, 2015

Edge sharpening with G'MIC "Gradient norm" and "Richardson-Lucy de-convolution" filters

Recently I've added two more G'MIC filters into PhotoFlow:

  1. The "Gradient norm" filter, which allows to identify the edges in an image and to create a convenient grayscale edge mask
  2. The "Richardson-Lucy de-convolution" filter for image sharpening, which generally yields better results than the standard Unsharp Mask technique
Combining both of them, it is possible to create a filter that selectively sharpens the image portions that are already "quite sharp", and leave untouched other smooth regions (like an out-of-focus background). The main interest of doing that is to avoid sharpening the noise in smooth areas. One can usually also increase the sharpening strength, because the effect is restricted by the edges mask. Moreover, the technique is not limited to the RL de-convolution filter, since the edge mask can be applied to any kind of sharpening tool. In PhotoFlow, you can currently choose between UnSharp Mask (USM) and RL de-convolution.

Below you can see the result of the edge masking filter, compared with the original image and a classic sharpening. For comparison, I've also added the output of edge-masked USM from PhotoFlow and RawTherapee, so that you can better compare the quality of the result with other existing open-source alternatives (it seems that there is no edge-masked sharpening available in Darktable for the moment).

Click type to see: Original - RL deconvolution sharpening - RL deconvolution edges sharpening - USM edges sharpening - USM edges sharpening (RawTherapee) - Edges mask

In this post I will not go into all details of how to create an edge-masked sharpening filter in PhotoFlow. Instead, I am providing a preset that automates the whole procedure, and I will only describe the few adjustment layers that have an impact on the output result (most of the layers in the preset are just buffers and copy operations). The screenshot below shows the preset in action, with some annotations that point to the relevant layers. The preset can be directly downloaded from here.

As you can see, the preset allows to directly visualize the edge mask being applied: for that, one has to select the "gradient norm" layer and activate the "show active layer" radio button below the preview area. Two parameters in the "Gradient norm" tool mainly control the generated mask: the "Threshold" value determines how much sharpening is applied in smooth areas, while the "Multiplier" value controls the amount of mask pixels that are purely white.

The "sharpening" layer lets you define the sharpening method (currently the standard Unsharp Maks and G'MIC "Richardson-Lucy de-convolution" are implemented) and its strength.

Finally, The "Halo control" group allows to optionally adjust the strength of the dark and light sharpening halos separately. I personally find that reducing the opacity of the light halos to 50% gives slightly better results.

The advantage of this approach is that the edge mask can be directly applied to any additional sharpening method that might be added in the future, and vice-versa new edge detection methods could be used to mask any of the existing sharpening filters.

No comments:

Post a Comment