Support my work on Patreon

If you like my work, please consider to help my growing family with a little financial support through my Patreon creator page.


Alternatively, you can leave a one-time donation via PayPal using the Donate button below.

Total Pageviews

Friday, March 27, 2015

Multi-scale decomposition with G'MIC and PhotoFlow



Mairi by Patrick David (cc by-sa)
Multi-scale editing of the forehead (mouse over to see original)

I've been silent for quite some time recently, for quite good reasons: I've been busy working on a new multi-scale decomposition tool, based on G'MIC "split_details" filter. Actually, porting the "split_details" filter was quite easy. The hard part has been to modify the processing engine so that it can handle multiple output images from one operation... but this is quite off-topic.

The multi-scale decomposition filter works in a similar way to the "Wavelet decompose" gimp filter: it creates a blurred base image and several separate layers containing the image details at increasing spatial frequencies. Each level has to be blended with the base image in "grain merge" mode in order to recreate the original. The various scales are obtained with classical gaussian blurs instead of wavelets, but apart from that they are equivalent to their wavelet counterparts.The filter is controlled by two parameters: the blur sizes of the smallest and largest detail scales, expressed in percent of the image dimensions. One needs to hit the "Update" button whenever one or both of the parameters is changed; this will trigger the re-computation of the various scales and will refresh the preview.


Image decomposition is typically used for skin retouching, and this post will be mostly devoted to this topic. However, I do not claim at all to be an expert of this technique.
Very briefly, the basic idea of skin retouching through multi-scale decomposition is to "erase" the unwanted elements in the layer where they are most prominent, leaving other details in higher or lower scales intact. For example, you might want to remove some visible skin defect without destroying the natural texture of the skin pores.
A very comprehensive introduction on the subject can be found on Patrick David's blog, here and here. From my side, I will limit myself at explaining how you can apply in PhotoFlow the techniques described by Patrick David.




The multi-scale decomposition filter is available in the "Details" tab of the layer chooser dialog. However, using this filter for skin retouching requires a bit of tedious "preparation work"... The good news is that I have already done all the work for you, and bundled into an handy preset that I strongly suggest to download and use as a starting point (you can get it from here).

Once loaded, the preset will create several group layers (one for each scale), with blend mode set to "grain merge". In this blend mode, the pixel values are added or subtracted depending wether they are above or below 50%; therefore, a value of exactly 50% does not modify anything.

Each group contains initially two layers, one with the details at the given scale and one filled uniformly with a 50% gray. The uniform 50% layer is associated with an opacity mask that is initially black, so that all image details are preserved by default in the final result.
In this configuration, unwanted details can be "erased" by simply drawing with a white pencil on the layer mask. The strength of the "detail suppression" can be controlled via the opacity of the 50% gray layer.

Of course, several other edits can be applied to the detail layers. Some examples are local gaussian blurs, or the healing brush to clone details from one place to another.






A practical example

Here is an example of the image decomposition in action. I've used a detail of the Mairi image, originally used in Patrick David's tutorial, for lack of a better idea and also for an easier comparison  with Patrick's own result... For this example I've used a "base scale" value of 0.2% and a "detail scale" value of 0.02%, and I've worked on the scales #5, #4 and #3.
First, I've enabled the "gray" layer in the "Scale 5" group, and then I've opened the layer mask  by double-clicking on the gradient icon.



Then I've double-clicked on the "gray mask" layer and I've started painting with a white brush of 20px, to progressively replace the large-scale details by an uniform 50% gray color.


The results of this step are shown below (click on the caption to see the original image, the original "scale #5" details, the final mask, the final "scale #5" details, and the resulting image).


Editing of the forehead on the details scale #5
Click type to see: Freehand mask - Details (scale #5) - Edited details - Image after scale #5 edit - Original


Next I have repeated the same operation on the 4th scale, this time on a smaller area in the center of the forehead (see below).


Editing of the forehead on the details scale #4
Click type to see: Freehand mask - Details (scale #4) - Image after scale #4 edit - Previous step

Finally, with two more strokes on the 3rd scale I have retouched just a bit more the two lines above the nose. The opacity of the gray layer was set at 50%, to show how one can produce very subtle changes through this method.


Editing of the forehead on the details scale #3
Click type to see: Freehand mask - Details (scale #3) - Image after scale #3 edit - Previous step


Conclusion

Of course this example if far from being a complete skin retouching tutorial, but it should be enough to give an idea of the potential of multi-scale decomposition and of how to use this technique in photoflow.

The nice thing is that the whole set of steps is non-destructive: the parameters of the scale decomposition as well as the edits of the individual scales can be tweaked at any moment with no limitations. When changing the decomposition parameters, it is necessary to click on the "Update" button in order to refresh the preview image. This will take a bit of time to complete, as the program needs to re-compute the different scales and cache the data again. Once the computation finished, all layers will be automatically updated to reflect the new settings.

Last but not least, this tool is fully integrated with the rest of the processing pipeline, and it is therefore possible to perform the skin retouching directly on a RAW image, without the need of an intermediate RAW converter.