From Avisynth wiki
Jump to: navigation, search
Author Asd-g
Version v1.0.0
Download vsTBilateral-
Category Spatial Denoisers
License GPLv2



vsTBilateral is a spatial smoothing filter that uses the bilateral filtering algorithm. It does a nice job of smoothing while retaining picture structure.

  • vsTBilateral is a port of the VapourSynth plugin TBilateral.


Syntax and Parameters

vsTBilateral (clip, clip "ppclip", int "diameterY", int "diameterU", int "diameterV", float "sdevY", float "sdevU", float "sdevV", float "idevY", float "idevU", float "idevV", float "csY", float "csU", float "csV", bool "d2", int "kerns", int "kerni", int "restype", int "y", int "u", int "v")

clip   =
A clip to process. It must be in 8..16-bit planar format.

clip  ppClip = NULL
Specifies a pre-filtered clip for TBilateral to take pixel values from when doing the luminance difference calculations.
The general recommendation for pre-processing is a Gaussian blur with standard deviation equal to the sDev settings being used.
Using a prefiltered clip should help in removing impulse noise (i.e. outliers with very large pixel differences) which standard bilateral filtering will not touch.
It does tend to produce artifacts sometimes, especially around very fine details. Another recommendation for pre-processing is a center-weighted median or adaptive median.
Must have the same format, dimensions, and number of frames as clip

int  diameterY = 5
int  diameterU = 5
int  diameterV = 5
Spatial diameters: this sets the size of the diameter of the filtering window.
Larger values mean more pixels will be included in the average, but are also slower.
Must be an odd number greater than 1. This must be less than the width of the video and less than the height of the video.

float  sdevY = 1.4
float  sdevU = 1.4
float  sdevV = 1.4
Spatial (domain) deviations; these set the spatial deviations.
The larger sDev is, the less effect distance will have in the weighting of pixels in the average. That is, as you increase sdev distant pixels will have more weight.
To get a better idea of what this setting does try setting idev to high values, and then gradually increase sdev from 0 on up while keeping idev constant. Increasing this setting will increase the strength of the smoothing.
Must be greater than 0.

float  idevY = 7.0
float  idevU = 7.0
float  idevV = 7.0
Pixel intensity (range) deviations; these set the pixel intensity deviations (or color deviations in the case of the chroma planes).
The larger idev is, the less effect pixel difference will have in the weighting of pixels in the average. That is, as you increase idev pixels that are very different from the current pixel will have more weight.
Try increasing these settings while keeping sdev constant to get a better idea of what these do. Increasing these settings will increase the strength of the smoothing.
Must be greater than 0.

float  csY = 1.0
float  csU = 1.0
float  csV = 1.0
Center pixel weight multipliers; these values are multiplied to the center pixel's spatial weight value.
A value of 1 does nothing, less than 1 means the center pixel will have less weight than normal, greater than 1 means the center pixel will have more weight than normal, 0 gives the center pixel no weight.
These must be at least 0. Setting cs to 0 will give you SUSAN denoising.

bool  d2 = false
This setting makes TBilateral use the second derivative instead of the first when doing the intensity calculations.
Using d2 should give better results on smooth gradients or anything that fits the piecewise linear model.
Setting d2 to False will give better results on images that have uniformly colored areas with sharp edges (anything that fits the piecewise constant model). The actual difference between the two is usually not big for most sources. The effect is rather subtle.

int  kerns = 2
This specifies what kernel is used for the domain weights.
  • 0 - Andrews' wave
  • 1 - El Fallah Ford
  • 2 - Gaussian
  • 3 - Huber’s mini-max
  • 4 - Lorentzian
  • 5 - Tukey bi-weight
  • 6 - Linear descent
  • 7 - Cosine
  • 8 - Flat
  • 9 - Inverse
See the following paper for a description of all the kernels and their properties: The Bilateral Median Filter.pdf

int  kerni = 2
This specifies what kernel is used for the range weights. The possible choices are the same as for kerns.

int  restype = 0
This specifies how the weights and pixel values are combined to obtain the final result.
  • 0 - Mean (weighted average)
  • 1 - Median (weighted median)
  • 2 - CW-Median (weighted median + extra center pixel weight)
  • 3 - MLR (multiple linear regression) (best fit plane)

int  y = 3
int  u = 3
int  v = 3
Planes to process.
  • 1 : Return garbage.
  • 2 : Copy plane.
  • 3 : Process plane. Always process planes when the clip is RGB.


vsTBilateral with default settings:

vsTBilateral (diameterY=5, diameterU=5, diameterV=5, sdevY=1.4, sdevU=1.4, sdevV=1.4, idevY=7.0, idevU=7.0, idevV=7.0, \
              csY=1.0, csU=1.0, csV=1.0, d2=false, kerns=2, kerni=2, restype=0, y=3, u=3, v=3)


Version      Date            Changes
v1.0.0 2020/07/19 - Initial release; port of the VapourSynth plugin - AviSynth+: self-registers as MT_MULTI_INSTANCE.

Archived Downloads

See GitHub releases page.

External Links

  • GitHub - Source code repository.

Back to External Filters

Personal tools