MipSmooth for AviSynth.

v0.9

This is the MipSmoother - a reinvention of SmoothHiQ and Convolution3D. MipSmooth was made to enable smoothing of larger pixel areas than 3x3(x3), to remove blocks and smoothing out low-frequency noise.
It is my hope that when this filter has been tweaked it will be better than C3D at smoothing out flat surfaces and gradients. This should be good for cartoons/anime, but it actually also helps film footage quite nicely.

Requirements:

Syntax:

Basic syntax: MipSmooth() - all parameters are optional.

Extended syntax:

MipSmooth([clip],[optional arguments])
There are a number of arguments that control how much smoothing will be applied:

preset = "MovieHQ" / "MovieLQ" / "AnimeHQ" / "AnimeLQ" / "VHS" / "Custom"
Loads a built-in preset as new defaults. See the preset section for more information.

spatial = 6,
temporal = 4,
spatial_chroma = 10,
temporal_chroma = 8,
scenechange = 5


All numbers are valid in the ranges 0 - 255 and this defines the threshold for each mode of blending.
The thresholds can be compared to the ones of C3D, except higher thresholds smooth much less than C3D.
The default settings are quite conservative, and only slightly smooths out surfaces.

"Temporal influence" is replaced by overall scenechange detection.  Scenechanges will disable temporal processing in either direction. Use "show = true" to display the values on each frame.

method  = "strong" / "soft"  - default: "strong"
This setting controls how much blurring is applied. The strong settings makes the filter have a larger impact, whereas soft is more gentle. In general strong should give best results on anime, and soft should be best for filmed material.

downsizer = "reduce", "point", "bilinear", "bicubic", "lanczos" - default: "reduce"
upsizer = "point", "bilinear", "bicubic", "lanczos" - default: "bilinear"
These two parameters control how the lower resolution maps are created. There might not be a very big visual impact, when using different resizers. Experiments are welcome!

scalefactor = 0.5
This option sets the scale of each mipmap. This is how much each frame is reduced in each iteration. The original resolution is multiplied by this value.  Usable values are from 0.2 to 4.0, however only values between 0.4 and 1.5 are recommended. When this setting is 1.0 no spatial blurring is done, but this isn't recommended - use spatial = 0 instead. Experiment with values above 1.0 - they might be useful.
When using the reduce downsizer, this setting is ignored (and 0.5 is always used).

mipsmooth(downsizer="lanczos",upsizer="bilinear", scalefactor=1.5, method = "strong") - produces very nice gentle smoothing for instance, but is very slow.

show = true / false
Shows information about scenechange differences, and the settings being used.
This setting will have no effect in RGB24 mode - use RGB32 instead!

storecustom = true / false
This will store the settings being used in the registry.
To reinvoke these presets later, use preset="custom" parameter.
This will not automatically become the default parameters.

Presets

Presets are a set of builtin settings to help you get started. The names of the parameters are not case sensitive.

All presets are loaded as default values. That means that it is still possible to finetune preset settings by setting individual parameters.


For example: MipSmooth(preset = "movieHQ", scenechange = 8) will use the MovieHQ, but with scenechange set to 8.

MovieHQ

This preset is for natual movies in high quality.

Spatial: 3
Temporal: 2
Spatial Chroma: 5
Temporal Chroma: 4
Scenechange: 4
Method: Soft
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.75

MovieLQ

This preset is for natural movies that need more smoothing, to have more blocks and noise removed.

Spatial: 6
Temporal: 4
Spatial Chroma: 10
Temporal Chroma: 5
Scenechange: 4
Method: Soft
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.75

VHS

Spatial: 8
Temporal: 5
Spatial Chroma: 10
Temporal Chroma: 8
Scenechange: 5
Method: Strong
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.75


AnimeHQ

This is for slight blockremoval and gradient restoration. It has more spatial smoothing than ordinary video to help recreate flat and gradient surfaces.

Spatial: 12

Temporal: 4
Spatial Chroma: 10
Temporal Chroma: 8
Scenechange: 5
Method: Soft
Downsizer: Bilinear
Upsizer: Bicubic
Scalefactor: 0.5

AnimeLQ

This is for more noisy material with more blocks and noise.

Spatial: 12
Temporal: 16
Spatial Chroma: 16
Temporal Chroma: 16
Scenechange: 8
Method: Strong
Downsizer: Bilinear
Upsizer: Bicubic
Scalefactor: 0.5

Custom

This will read settings that has been stored in the registry, and use these as default settings.
If there is no settings stored in the registry, an error will be thrown.
At any time it is possible to use "storecustom=true" this will then store the current settings in the registry, and these will then be used as the custom parameters

Background information:

"Mip" comes from "MipMap", which is a term used in the realtime 3D-graphics world, and basicly describes a downsampled version of a texture (bitmap surfaces of 3D objects), that is used, when the object is far away.  MipMaps are always half the size of the original image.

What MipSmooth does is actually very simple:

It takes the source frame, and creates three new versions, each half the size of the previous. This is done by using ReduceBy2, or a selectable resizer. These frames are then all scaled back up to original size using BilinearResize.  These frames are then compared to the original, and if the difference is below the threshold, the information is used to form the final pixel.

The same is done to the previous and the next frame - and all these three frames and their "blurred" mipmaps are used to reconstruct each pixel.
Threshold is adjusted to that more blurred images are given a lower threshold than the sharper versions.

Further possible improvements:

Changes:

v0.9: 
* Added presets.
* Added storecustom parameter to store a custom preset.
* Capable of running YUY2 material. For now chroma thresholds are ignored in YUY2.
* Capable of running in RGB mode (RGB24 and RGB32).
* The Reduce downsizer is now interchangeable with bilinear, and only used when the settings allow it.
* "show=true" now displays information onscreen.
* Fixed: Luma thresholds were also being used as chroma thresholds.

v0.2:
* Added optional resizers.
* Added "strong" method - now default. Previous default was "soft".
* Added scalefactor to allow different mip scaling.
* Mod 16 restriction lifted with new downscalers.

v0.1:
* Initial release.