From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (Requirements)
(New pfmod version 1.1.1c)
Line 7: Line 7:
<span style="color:red">'''AviSynth+ 3.5.2 or greater'''</span>
<span style="color:red">'''AviSynth+ 3.5.2 or greater'''</span>
[ KNLMeansCL_1.1.1_test_for_avs3.5.2.7z]
[ KNLMeansCL_1.1.1c_v20201028-pfmod.7z]
|4=Spatial-Temporal Denoisers
|4=Spatial-Temporal Denoisers
|5=[ GPLv3]
|5=[ GPLv3]

Revision as of 20:30, 1 November 2020

Author Khanattila
Version v1.1.1

AviSynth+ 3.5.2 or greater KNLMeansCL_1.1.1c_v20201028-pfmod.7z

Category Spatial-Temporal Denoisers
License GPLv3
Discussion Doom9 Thread



KNLMeansCL is an optimized OpenCL implementation of the Non-local means de-noising algorithm. The NLMeans filter, originally proposed by Buades et al., is a very popular filter for the removal of white Gaussian noise, due to its simplicity and excellent performance. The strength of this algorithm is to exploit the repetitive character of the image in order to de-noise the image unlike conventional de-noising algorithms, which typically operate in a local neighbourhood.

NOTE: for AviSynth+ 3.5.2 or greater, use this test version here:


*** vc_redist.x86.exe is required for KNLMeansCL-x86
*** vc_redist.x64.exe is required for KNLMeansCL-x64

Syntax and Parameters

KNLMeansCL (clip, int "d", int "a", int "s", float "h", string "channels", int "wmode", float "wref", clip "rclip", string "device_type", int "device_id", int "ocl_x", int "ocl_y", int "ocl_r", bool "stacked", bool "info")

clip   =
Input clip; 8192x8192 is the highest resolution supported.

int  d = 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 = 2
Set the radius of the search window. a=0 uses 1 pixel, while a=1 uses 9 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 = 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 = 1.2
Controls the strength of the filtering. Larger values will remove more noise.

string  channels = "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".


int  wmode = 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 = 1.0
Amount of original pixel to contribute to the filter output, relative to the weight of the most similar pixel found.

clip  rclip =
Extra reference clip option to do weighting calculation.


string  device_type = "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 = 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 = 0
int  ocl_y = 0
int  ocl_r = 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.


bool  stacked = false
AviSynth hack. Set 16-bit stacked input and output clip. See Stack16 for more info.
AviSynth+ supports native high bit depth; this hack is only for AviSynth 2.6.

bool  info = false
Display info on the screen. It requires YUV colour space.


KNLMeansCL with all default settings:




External Links

  • GitHub - Source code repository.

Back to External Filters

Personal tools