Skip to content
Edoardo Brunetti edited this page Dec 17, 2020 · 32 revisions

Syntax

AviSynth
KNLMeansCL(clip, int d, int a, int s, float h, string channels, int wmode, float wref, clip rclip, string device_type, int device_id, bool lsb_inout, bool info)

VapourSynth
knlm.KNLMeansCL(clip clip, int d, int a, int s, float h, string channels, int wmode, float wref, clip rclip, string device_type, int device_id, bool info)

Basic

clip clip
Video source: 8192x8192 is the highest resolution supported.

int d [default: 1]
Set the number of past and future frame that the filter uses for denoising the current frame. d=0 uses 1 frame, while d=1 uses 3 frames and so on. Usually, larger it the better the result of the denoising. Temporal size = (2 * d + 1).

int a [default: 2]
Set the radius of the search window. a=1 uses 9 pixel, while a=2 uses 25 pixels and so on. Usually, larger it the better the result of the denoising. Spatial size = (2 * a + 1)^2.

Tip: total search window size = temporal size * spatial size.

int s [default: 4]
Set the radius of the similarity neighbourhood window. The impact on performance is low, therefore it depends on the nature of the noise. Similarity neighborhood size = (2 * s + 1)^2.

float h [default: 1.2]
Controls the strength of the filtering. Larger values will remove more noise.

bool cmode [default: false]
Use colour distance instead of grey intensities. Normally KNLMeansCL processes only Luma and copy Chroma if present. If cmode is true KNLMeansCL processes Luma and Chroma together. If colour space is RGB, cmode is always true.

string channels [default: "auto"]
Set the colour channels to be denoised. Possible values are "YUV", "Y", "UV" or "RGB", depending on the source colour format. By default, "Y" is denoised if colour space is YUV, otherwise "RGB".

Advanced

int wmode [default: 1]
0 := Cauchy weighting function has a very slow decay. It assigns larger weights to dissimilar blocks than the Leclerc robust function, which will eventually lead to over-smoothing.
1 := Welsch weighting function has a faster decay, but still assigns positive weights to dissimilar blocks. Original Non-local means denoising weighting function.
2 := Bisquare weighting function use a soft threshold to compare neighbourhoods (the weight is 0 as soon as a given threshold is exceeded).

int wmode [default: 0]
0 := Welsch weighting function has a faster decay, but still assigns positive weights to dissimilar blocks. Original Non-local means denoising weighting function.
1 := Modified Bisquare weighting function to be less robust.
2 := Bisquare weighting function use a soft threshold to compare neighbourhoods (the weight is 0 as soon as a given threshold is exceeded).
3 := Modified Bisquare weighting function to be even more robust.

float wref [default: 1.0]
Amount of original pixel to contribute to the filter output, relative to the weight of the most similar pixel found.

clip rclip [default: not set]
Extra reference clip option to do weighting calculation.

OpenCL

string device_type [default: "auto"]
"accelerator" := Dedicated OpenCL accelerators.
"cpu" := An OpenCL device that is the host processor.
"gpu" := An OpenCL device that is a GPU.
"auto" := "accelerator" -> "gpu" -> "cpu".

int device_id [default: 0]
The 'device_id'+1º device of type 'device_type' in the system. Example: [device_type = "GPU", device_id = 1] return the second GPU in the system.

int ocl_x, ocl_y, ocl_r [default: 0]
They should not be changed, unless you know what you are doing. 'ocl_x' and 'olc_y' are the local work group size of the separable convolution kernel. 'olc_r' is the number of processed pixel for work-item.

Miscellaneous

bool lsb_inout [default: false]
bool stacked [default: false]
AviSynth hack. Set 16-bit input and output clip.

bool info [default: false]
Display info on the screen. It requires YUV colour space.