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, April 3, 2015

The clone-stamp tool

The "clone stamp" tool has been recently redesigned and completed, and now it is fully functional.
The tool can be found in the "misc" tab of the layer chooser dialog:


The usage of the tool is pretty easy: one has first to define a source region by left-clicking on the preview area while holding down the Ctrl-Alt keys. A circle shows the size of the area being cloned.


Once the source area is selected, there will be two circles shown in the preview: one corresponds to the current mouse position, the other to the area being cloned:


The pixels are cloned by dragging the mouse while holding down the left mouse button:



The clone/stamp tool is controlled by three parameters: the size of the brush, the opacity with which the cloned pixels are overlaid with the original ones, and the smoothness of the brush edges. The image below shows the same area cloned wih a brush smoothness of 100%, 50% and 0%:



The new  clone/stamp tool is available from the develop branch of the github repository or from the updated Windows and OSX installers.

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.

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.

Saturday, February 14, 2015

"Autumn at the National Rhododendron Gardens" edit - Part 2: more sky editing

In this second part of the step-by-step description of my final edit of the image in this google+ post of the "Open Source Edit my RAW" discussion group, I want to introduce another simple yet powerful technique for enhancing the sky in landscape pictures.

The technique consists in blending the "b" Lab channel with the original image in "Overlay" mode. Below you can see a comparison between the original image, the result of the previous step, the result of the "b" channel blend and the "b" channel itself.



Click type to see: Original - Step 1 result - "b" channel Overlay result - "b" channel

In the "b" channel, anything that contains some blue is below 50% and gets darkened in the overlay blend, while "yellowish" areas (including leaves and grass) are above 50% and result in lighter tones after blending. In order to keep the lightness of the tree and grass close to the original, I've added a slightly darkening tone curve to the Overlay blending input. The tone curve, as well as the settings for the "b" channel blend, can be seen in the screenshot below.



The nice thing with this technique and the one described in the previous post, is that the result is achieved using only the image data itself, without any masking. The effect is therefore very "natural", without any presence of disturbing halos in the transition areas.

In order to simplify the application of this steps, I've prepared a preset that automatically adds a group layer containing both the red channel blend and the "b" channel overlay. The preset can be downloaded from here. 
The technique turns out to be also quite powerful for haze removal. Below I have applied the preset to the RAW image shared in this google+ post (mouse over to see original image):


Saturday, February 7, 2015

"Autumn at the National Rhododendron Gardens" edit - Part 1: the sky

This post describes step-by-step how I've obtained the final edit of the image in this google+ post of the "Open Source Edit my RAW" discussion group. You can see the final result here.

When editing this picture I had few guiding ideas in mind:

  • the sky was too bright, and I wanted to obtain a more saturated blu tint as well as more contrast and "texture" in the clouds
  • the tree in the foreground is the main element of the composition, so I wanted to give it some "pop"
  • the scene gave me a "late afternoon" feeling, so I wanted to add some overall warm tone

The starting point is the original RAW image, processed using the in-camera settings and the standard Adobe color matrices (for a detailed tutorial on how to open and process a RAW image, see here).

Let's see my editing step-by-step, starting from the sky and clouds. Actually, the techniques described in this and the next posts are not really peculiar to PhotoFlow, and most likely can be applied with minor modifications in other image editors.

Part 1: sky editing

In oder to darken the sky and clouds, I will use a rather common but very powerfull technique, which consists in replacing the luminosity channel of the original image with its own RED channel, and then blend the result back with the original image in "Darken" mode.

The screenshots below shows how this can be achieved in PhotoFlow.





Here are the detailed steps that I've followed:
  1. Add a group layer (I've called it "Sky edit") above the developed RAW image (new groups can be created by clicking on the "G+" button).
  2. Add a "clone" layer inside the group: for that, you have to select the empty row below the group name, than click on the "+" button to open the tool chooser dialog, and then select the "Clone layer" row in the "Misc" tab before clicking the "OK" button to close the dialog.
  3. In the "clone layer" configuration dialog that will pop up, you have to choose the layer corresponding to the initial image (in my vcase "RAW developer") for the layer name, and the "R" channel for the source. The image is graysacle at this point, since we only cloned one channel. To "restore" the colors, set the  blend mode to "Luminosity".
  4. You will notice at this point that the sky got quite darker, but the reddish leaves in the trees became very bright. What we would like is to keep what is darker in this R channel blend, and preserve everything else from the original image... to achieve this, you have to change the blend mode of the "Sky edit" group from "Normal" to "Darken"


There it is! The sky has now a deeper blue and more contrast in the clouds, all that without any masking and unwanted halos around the transition regions. Click on the caption elements to see the original image, the red channel, and the luminosity blend before the final "Darken" blend.



Click type to see: Original - Red channel - R channel Luminosity blend - Final result
  
The next part will show how the contrast in the foreground tree has been improved through a mid-tones liminosity mask associated to a curves adjustment.

Tuesday, January 27, 2015

Basic batch processing with PhotoFlow

The development branch of PhotoFlow now provides a new command that allows some basic batch processing. The batch processor is called pfbatch and gets installed in the same directory as the interactive photoflow command.

The general syntax of the pfbatch command is the following:

    pfbatch input_file [preset_1]...[preset_n] output_file

and can be used to perform different kind of tasks:
  • export an existing PFI file to TIFF or JPeg, optionally applying additional presets (I'll come back to that later in this post)
  • load a TIFF or JPeg file and save it as PFI file
  • load a TIFF or JPeg file, apply some presets and export again as  TIFF or JPeg
  • load a PFI file,  append some presets and save again as PFI

To make a concrete example, let's assume you have a certain number of edited images (saved as PFI files), and you want to create down-scaled versions to be posted on the web. You probably also want the web images to be converted to sRGB, just to make sure that they will display at least decently even on browsers that ignore ICC profiles.

The downscaling and sRGB conversions are additional operations that are not contained in the input PFI files, and that have to be applied to each image we are converting. All we need to do is to create a couple of presets for that, and then append them to the input file when calling pfbatch.

In order to create the presets, you first need to open an existing image with photoflow, and then add any layer that you want to save as a preset.

The example below shows how to add a "Scale & rotate" layer to an existing image: we will use this tool to create a preset that scales the image to a size of 800x600 pixels at most (the "Scale & rotate" tool is found under the "geom" tab of the "new layer" dialog).



Now we have to adjust the parameters of the scale tool so that the final image will fit into 800x600 pixels. The scale tool in PhotoFlow works similar to the "-resize" command in ImageMagick: when scaling the image, the tool will preserve its aspect ratio and will make sure that the resulting image fits into the given size. Therefore, we simply need to specify the desired size (in pixels) in the correspoding tool dialog:



At this point, with the "resize" layer still selected, click on the "Save" button below the layers list to save it as a preset (with extension ".pfp"):



In the following I will assume that you have saved this preset as "$HOME/presets/web_resize.pfp".

Now you have to do the same for the sRGB conversion: add one more layer of type "Color profile conversion" (you will find it in the "conv" tab of the "new layer" dialog) and leave the parameters to their defaults. In my case, the layer is simply named "sRGB":



Make sure that only the "sRGB" layer is selected, then click on the "Save" button below the layers list to save it as an additional preset (I'll assume you have called it "$HOME/presets/sRGB.pfp").

You can also save several layers in one single preset, either by selecting them before clicking on the "Save" button, or by inserting them into a group layer and saving the group itself as a preset.

At this point, everything is ready to batch-convert your first image for the web (of course you need to replace the input and output file names with your actual files):

    pfbatch input.pfi $HOME/presets/web_resize.pfp $HOME/presets/sRGB.pfp output_4web.jpg

This command can also be used inside a Makefile. Here is how a generic rule could look like:

    Web/%.jpg: %.pfi
        pfbatch $< $HOME/presets/web_resize.pfp $HOME/presets/sRGB.pfp $@

 This will run through all the *.pfi files in the current directory and save the resulting resized JPeg files in the "Web" subdirectory.

For the future I am planning to make the batch processing tool more intuitive and user-friendly, and add some GUI interface to it. However, the pfbatch commmand will most likely remain there as the basic building block for everything else...

Monday, January 12, 2015

Experimental LensFun support added into PhotoFlow

An initial implementation of LensFun support has been added into PhotoFlow.

The tool is still experimental, and limited in functionality:
  • the camera and lens information can only be extracted from the EXIF metadata, and not specified by hand
  • only distorsion and TCA corrections are implemented for the moment, the vignetting is still missing
  • there is no possibility yet to select the corrections to be applied
  • the interpolation is performed using a simple nearest neighbour method, to be replaced with a better interpolator in future


Nevertheless, if you are interested in this feature and you want to help me in the testing and debugging process, the tool can be accessed from the "Geometry" tab of the tool selector. The tool is called "Optical corrections":


Here is how the tool dialog looks like:


The LensFun tool is for the moment only available from the GitHub sources.
Two additional dependencies are needed to compile PhotoFlow: exiv2 and LensFun.

As any other experimental code, it still contains bugs and is likely to produce frequent crashes, therefore I recommend to frequently save your work while testing it.