Anisotropic Smoothing - GreycLab/gmic-community GitHub Wiki

CImg blur_anisotropic( ... ) G'MIC script -smooth ... G'MIC Gimp filter Enhancement / Smooth [anisotropic]

Mechanics

A PDE is applied which locally blurs the image according to a tensor field.

The tensor field may be supplied as an image argument, a 2-d tensor requires three components.

Otherwise a "diffusion tensor" is computed from the same image to which the blur is applied. This tensor is derived from the "structure tensor" of second derivatives xx xy yy such that it is zero at an edge uniform away from an edge and aligned as it approaches an edge.

Usage

This is a non-linear filter suitable for suppressing high-frequency noise.

By blurring an image by its own diffusion tensor the sharpness of linear features tends to be retained as blurring occurs parallel to the local orientation.

Comments on Arguments

effect:

  • Amplitude

1-10 amount of smoothing to apply

  • Diffusion Tensor - Sharpness

power law applied to steepness of gradient

  • Diffusion Tensor - Anisotropy

power law applied to correlation

  • Diffusion Tensor - Gradient Smoothness (alpha)

pre-blur image before calculating structure tensor

  • Diffusion Tensor - Tensor Smoothness (sigma)

post-blur tensors after calculating structure tensor

  • Spatial Precision (dl)

The step size in the Line Integral Convolution.

  • Angular Precision (da)

The step size of the angular resolution the Tensor Field is decomposed into. The lower the value the more anistropic the effect.

  • Value Precision (prec)

internal to PDE solver ?

  • Interpolation {Nearest neighbor, Linear, Runge-Kutta}

Method used to compute the Line Integral.

  • Fast Approximation {0, 1}

internal to PDE solver ?

NOTES

The word 'anisotropic' means the opposite of 'isotropic' (the same in all directions). The quality of acting differently according to an angle is very common in real life materials' reflectivity, for example hair or velvet or brushed metal where the angle of incident light affects where you see highlights. For smoothing images there is a desire to retain visibly sharp edges and yet blur small dots (speckles) or amorphous noise. Doing that requires a (globally) non-linear filter sensitive to (local) orientation. A brute force method would try every direction and look for a "best fit", a more efficient method is to estimate the best direction and use that. The problem with estimations from a noisy source is you might get what looks like an "edge" by chance just from noise.

The jargon here is a bit of maths called a tensor which is a function has a vector or matrix-like value. Scalar valued functions have a vector gradient, each element of that vector can also have a gradient. A second order tensor like that can represent twistiness (or curl).

The Structure Tensor is the second-order derivative .. given a grayscale input it returns Ixx Ixy Iyy, the various gradients of the gradient (note that Ixy=Iyx so we only need these three items in 2d).

The Diffusion Tensor is a normalised (regularised) version of the Structure Tensor, encoding relative importance of local "direction".

The G'MIC -smooth function boils down to cimg::blur_anisotropic for a specific tensor either supplied as an argument or computed.

10 argument version

amplitude>=0 sharpness>=0 anisotropy [0-1] alpha # Standard deviation of the gradient blur sigma # Standard deviation of the structure tensor blur dl>0 # Spatial discretization da>0 # Angular discretization - if 7th argument is 0 then see below gaussian precision>0 # Precision of the diffusion process interpolation method fast_approx={ 0 | 1 }

[tensor]=cimg::get_diffusion_tensors(sharpness,anisotropy,alpha,sigma,interpolation_type!=3) cimg::blur_anisotropic([tensor],amplitude,dl,da,gauss_prec,interpolation_type,is_fast_approx)

7 argument version starting number ending zero

nb_iterations>=0 sharpness>=0 anisotropy alpha sigma dt>0 0 #required

7 argument version starting tensor image

[tensor_field] amplitude>=0 dl>0 da>0 # if 4th argument is 0 then see below precision>0 interpolation fast_approx={ 0 | 1 }

4 argument version ending zero

[tensor_field] nb_iters>=0 dt>0 0

cimg::blur_anisotropic(tensors,amplitude,dl,da,gauss_prec,interpolation,is_fast_approximation)