Tutorial

# G'mic: anisotropic smoothing

### 0-Introduction

coucou ca marche? This page intends to help the use of the GIMP plugin filter anisotropic smoothing from the enhancement folder.
The G'mic anisotropic smoothing is an implementation of the smoothing filter described in this technical paper. Basically, the filter analyses the image to identify the structures and then smooth parallel to it , thus preserving the details.
This doc explains step by step in the hope that you understand the influence of each option. It uses a simple example to illustrate: a noised grey disc (see below).
The left hand-side image above is the original "clean disc". The right hand-side one is the noised one. The purpose is to get back (as much as possible) to the original one using the anisotropic smoothing filter.
Those two images can be made using the following command lines:
gmic 100,100,1,3 -fill 100 -ellipse 50,50,30,30,0,1,150,150,150 -o clean_disc.png
gmic clean_disc.png -noise 30 -n 0,255 -o disc.png

### 1-Image structure analysis

To localize the structure of the image you intend to filter, G'MIC uses gradient calculations since high gradient means high color variations and thus the border of a certain structure.
But, the presence of noise in an image produces rather high color variation between concecutive pixel where there is actually no structure border. To handle this issue, the image is blurred before the gradient calculations so that the noise is smeared over a small distance. The parameter that controls that blur is the paramater called gradient smoothness. It therefore sets the limit between what should be considered as noise or as structure.
Once the gradient computations are done, it is obtained what is called a structure tensor, that defines to the filter where it should act most (far from the structure borders). In practice, this structure tensor undergoes a second blurring in order to reduce the abruptness of the structure definition, thus increasing the size of the zones where the filter should have a intermediate behavior. The parameter regulating this second blurring is called the tensor smoothness. It can (for instance) diminish artefacts that may appear close to structure borders.
The pictures below show the structure tensors as analyzed by G'mic.
The left image is obtained using gradient_smoothness=0 and tensor_smoothness=0. It can be seen that the disc border is detected, but many pixels far from the border also have high values and will thus be interpreted as structure borders by the filter.
The middle image is obtained using the default setting (gradient_smoothness=0.6 and tensor_smoothness=1.1). Better, but stille noisy. Our simple image makes us expect better.
The right image is obtained using a stronger blurring (gradient_smoothness=3 and tensor_smoothness=1). The noise is almost completely removed, it will be our structure tensor in the rest of this doc.
Those three images can be made using the following command lines:
gradient_tensor=0;tensor_smoothness=0;
gmic disc.png -blur $gradient_tensor -gradient xy --*[-2] [-1] -*[-1] 2 -sqr[-3,-2] -a x -s v -+ -s x,3 -mv[-1] -2 -a v -blur $tensor_smoothness -n 0,255 -o raw_structure_tensor.png
gradient_tensor=0.6;tensor_smoothness=1.1;
gmic disc.png -blur $gradient_tensor -gradient xy --*[-2] [-1] -*[-1] 2 -sqr[-3,-2] -a x -s v -+ -s x,3 -mv[-1] -2 -a v -blur $tensor_smoothness -n 0,255 -o default_structure_tensor.png
gradient_tensor=3;tensor_smoothness=1;
gmic disc.png -blur $gradient_tensor -gradient xy --*[-2] [-1] -*[-1] 2 -sqr[-3,-2] -a x -s v -+ -s x,3 -mv[-1] -2 -a v -blur $tensor_smoothness -n 0,255 -o personalized_structure_tensor.png

### 2-Filter behavior

Once the structure is detected, it is time to tell the filter how to behave with it.
The parameter sharpness gives the threshold used to separate areas that deserves a strong or a weak smoothing. A too low value and the whole image becomes eligible for the maximum smoothing. At the opposite, a too high value means no smoothing at all.
The parameter anisotropy gives the amount of anisotropy of the filter. Set as 0, your filter isn't anisotropic anymore, but if it is set too high, some serpentine artefact might appear on your image.
The left image above comes from a smoothing using a reasonnable level of anisotropy (0.3), whereas the right one let appear some serpentine artefact because of too much anisotropy (1.0).
Those two images can be made using the following command lines:
gradient_tensor=3;tensor_smoothness=1;sharpness=0.4;anisotropy=0.3;
gmic disc.png -smooth 100,$sharpness,$anisotropy,$gradient_tensor,$tensor_smoothness -o fixed_disc.png
gradient_tensor=3;tensor_smoothness=1;sharpness=0.4;anisotropy=1;
gmic disc.png -smooth 100,$sharpness,$anisotropy,$gradient_tensor,$tensor_smoothness -o high_anisotropy_disc.png

### 3-Strength

The strength of the filtering is set by the amplitude parameter.
Another way to increase the amount of smoothing applied to your image is to increase the number of iterations. 2 iterations means that you apply again the same filter on your already once filtered image.

### 4-Accuracy

You should probably not modify the parameters discussed here since their default values seems corrects for any image type.
The three "precision" parameters: spatial precision, value precision and angular precision are mathematical parameters related to the level of discretization used to solve the differential equations of the filter. A lower value means a better accuracy at the expense of processing time. Difference between value et spatial precision?
This algorithm used for this filter may go to some sub-pixel accuracy. The parameter interpolation type tells how the value between 2 pixels should be estimated. Runge-Kutta is luxury.
Checking the fast approximation box allows the filter to use a slightly simpler but much faster algorithm. to be confirmed

### 5-Others

By default, the filter consider the image values from the RGB (or RGBA) channels, but it can be modified with the channels processing parameter. to be confirmed
If you use this filter on a large image, your computer might run out of memory. In that case, you can increase the number of tile subdivisions. Your image will be cut in several pieces and the filter applied on each piece sequentially.

### 6-And then?

Like all smoothing filter, this anisotropic one might let you feel that some details on your image have vanished. It is probably a good idea to add a slight edge enhancement filter like unsharp masking.
CC-BY-SA
bad English?
rough aesthetics?
less clear than unclear?
need to talk?
zonder #@# tuxfamily.org