                                    TNLMeans for VapourSynth
        originally for AviSynth v2.5.x by tritical, and for VapourSynth by Yusuke Nakamura

                                             HELP FILE
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------


INFO:


      TNLMeans is an implementation of the NL-means denoising algorithm. Aside from the original
   method, TNLMeans also supports extension into 3D and a faster, block based approach.


   Syntax =>

      tnlm.TNLMeans(int ax, int ay, int az, int sx, int sy, int bx, int by, float a, float h, int ssd)



THEORY OF OPERATION:


      The NL-means algorithm works in the following manner.  For each pixel in the image define
   a search window in which to look for similar pixels.  The search window is defined by the
   parameters ax and ay, which set the x-axis radius and y-axis radius.  For each pixel in the
   window determine a weight based on the similarity of that pixel's gray level neighborhood to
   the center pixel's gray level neighborhood.  The neighborhood is defined by the sx and sy
   parameters, which set the x-axis radius and y-axis radius.  The similarity between two
   neighborhoods is measured using gaussian weighted (as a function of distance, the standard
   deviation is set by the "a" parameter) sum of squared differences. The final weight for a pixel
   is computed as:

          exp(-(total_sse_difference/sum_of_gaussian_weights)/(h*h));

   If the parameter 'ssd' is set to false, then sum of absolute differences is used instead of
   sum of squared differences.  In that case, the final weight for a pixel is computed as:

          exp(-(total_sad_difference/sum_of_gaussian_weights)/h);

      Once a weight for each pixel in the window is acquired, the final pixel value is simply
   the weighted average of all the pixels.  In order for the center pixel to not be too heavily
   weighted, it is assigned a weight equal to the largest weight given to another pixel in the
   search window.

      The block based modification changes the base step (or base window) from 1 pixel to blocks
   with size bx and by where bx and by set the x-axis radius and y-axis radius. The support and
   search windows still work the same way, but now whole blocks are computed/averaged at once
   instead of individual pixels.  This modification cuts the computation time down by
   (bx*2+1)*(by*2+1) times.

      The 3D extension allows extending the search window into neighbor frames.  The parameter
   az sets the temporal (z-axis) radius.  With az=1 frames n-1 and n+1 would be included.

      More information can be found by following the links to papers about NL-means under
   the TNLMeans portion of http://bengal.missouri.edu/~kes25c/.



PARAMETERS:


   ax, ay, az -

      These set the x-axis, y-axis, and z-axis radii of the search window.  These must be
      greater than or equal to 0.  The full window size will be:

           (ax*2+1) x (ay*2+1) x (az*2+1)

      Generally, the larger the search window the better the result of the denoising. Of
      course, the larger the search window the longer the denoising takes.

      Default:  ax = 4 (int)
                ay = 4 (int)
                az = 0 (int)


   sx, sy -

      These set the x-axis and y-axis radii of the support (similarity neighborhood) window.
      These must be greater than or equal to 0.  A larger similarity window will retain more
      detail/texture but will also cause less noise removal.  Typical values for sx/sy are 2
      or 3.  The full window size will be:

           (sx*2+1) x (sy*2+1)

      Default:  sx = 2 (int)
                sy = 2 (int)


   bx, by -

      These set the x-axis and y-axis radii of the base window.  In the original NL-means
      algorithm the base was a single pixel (bx=0 and by=0).  Using blocks larger than a
      single pixel will sacrifice some quality for speed.  Note that sx must be greater than
      or equal to bx and sy must be greater than or equal to by.  It is recommended that
      sx/sy be larger than bx/by.

      Default:  bx = 1 (int)
                by = 1 (int)


   a -

      Sets the standard deviation of the gaussian used for weighting the difference calculation
      used for computing neighborhood similarity.  Smaller values will result in less noise removal
      but will retain more detail/texture.

      Default:  1.0 (float)


   h -

      Controls the strength of the filtering (blurring).  Larger values will remove more noise
      but will also destroy more detail. 'h' should typically be set equal to the standard deviation
      of the noise in the image when using ssd=true and assuming the noise fits the zero mean,
      gaussian model.

      Default:  if ssd = 1 - 1.8 (float)
                if ssd = 0 - 0.5 (float)


   ssd -

      Controls whether sum of squared differences or sum of absolute differences is used when
      computing neighborhood similarity. ssd is slightly slower but retains fine detail/texture
      better.  sad typically works better for cartoons/anime.  The 'h' parameter usually needs
      to be set about 4 times lower when using sad than when using ssd.

         1 - use ssd
         0 - use sad

      Default:  1



CHANGE LIST:

   02/22/2015

       - Supported up to 16 bit-depth per plane.

   01/15/2015

       - Supported VapourSynth native frame-based multi-threading.

   01/14/2015

       + Imported for VapourSynth.
       + Supported all planar 8-bit formats.
       + Use VapourSynth native reference counting for frame data instead of copying.
       - Removed YUY2 format support.
       - Removed multiscale version (parameters ms/rm).
       - Renamed 'sse' to 'ssd'.
       - Renamed all parameters into lowercases because of the plugin guidelines.


CHANGE LIST (from the AviSynth plugin):


   08/28/2007  v1.0.3

       - Removed fast exp() approximation that was used for sse=false.  Turns out it was quite
            inaccurate and had overflow problems resulting in artifacts.


   07/30/2006  v1.0.2

       - Fixed a problem with small weights causing artifacts


   06/19/2006  v1.0.1

       - Fixed a bug that caused a crash when ms=true was used with yuy2 input


   05/31/2006  v1.0 Final

       - Fixed always creating the downsampled clip unless ms=false was explicitly
           specified


   05/25/2006  v1.0 Beta 2

       + Added multiscale version (parameters ms/rm)
       + Added sse parameter
       + optimized non-block based routines by buffering (100% speed increase)
       - removed b parameter
       - fixed a bug in the block based routines that caused some blocks
           in the search window not to be tested
       - changed defaults for ax/ay/sx/sy/h


   05/17/2006  v1.0 Beta 1

       - Initial Release
