Smart Smoother High Quality
V 2.11
Plugin for Avery Lee's Virtual Dub by Klaus Post.
Introduction:
This filter performs smoothing on video material to eliminate noise and MPEG artefacts. This filter makes it possible to blur out noise and still retain a fair amount of detail. Rewritten on basis of Smart Smooth 1.1 by Donald Graft. This implementation has been made to supplement the original Smart Smoother by producing better results on ordinary video.
Download:
[Download binaries] v2.11 (Athlon MMX optimized)
[Download binaries] v2.11 (K6-III, P3, P4 MMX version)
[Download binaries] v2.11 (No MMX version)
[Download source code] v2.11 (MSVC 6 + preprocessor pack 5).
Installation:
Virtual Dub / NanDub
Unzip (Using WinZip, WinRar or Windows Commander) into the plugin directory of your Virtual Dub / Nandub installation. Then the filter will show up in the filters menu.
AviSynth
Use the VirtualDub Filters Import File. If you know how to use AviSynth, you'll know how to use this :)
For a more updated version it might be necessary to search Doom9's forums.
If you won't be bothered by getting this script here is a sample script (thanks Acaila):
##########################################
# Smart Smoother HiQ by Klaus Post, v2.1 #
# #
# diameter (3-13, odd), #
# threshold (1-200), amount (1-254) #
# difference (0-50) #
# mode = "average" or "weighted" #
# weighted_difference = weigh with diff. #
##########################################
function VD_SmartSmoothHiQ(clip, int "diameter", int "threshold", int "amount", string "mode",
\ bool "grayscale", bool "weighted_difference", int "maintain_diffweight")
{
LoadVirtualdubPlugin(VirtualDub_plugin_directory+"\SmoothHiQ.vdf", "_VD_SmartSmoothHiQ")
mode = default(mode, "weighted")
mode = (mode=="average") ? 0 : (mode=="weighted") ? 1 : -1
Assert(mode>=0, """VD_SmartSmoothHiQ: "mode" parameter must be "average" or "weighted"""")
return clip._VD_SmartSmoothHiQ(default(diameter,5), default(threshold,50), 0, default(amount,254),
\ mode, default(grayscale,false)?1:0, default(weighted_difference,true)?1:0, default(maintain_diffweight,0))
}
# example:
# ConvertToRGB()
# VD_SmartSmoothHiQ(5,50,254,"weighted")
# ConvertToYUY2()
How it works:
The filter settings looks like this:
The filter works in two modes, that performs the same tasks. You have to define a diameter on which the filter operates. The bigger the diameter the bigger is the areas that may be blurred. Bigger diameters usually means better results - but at the cost of speed. 5 or 7 is recommended.
You also have to define a threshold. The threshold is an indication of how close the color of the pixels must be to be blended together. If the difference between the pixels are bigger that the threshold, they will not influence eachother. The threshold can be tested in either seperate colors or greyscale. In most cases you should use use color (by not enabling grayscale). But if your source has bad colors (from VHS or similar), you can use this mode to blend different colors better. Color and Greyscale tests are equally fast - color perhaps even very slightly faster.
The filter processes the pixels in a diamond shape, to avoid blurring areas that are not connected.
The window (diameter:5) around a pixel P. The arrows show how the filter progresses. If the pixel with the arrow doesn't clear the threshold the filter will not progress beyond it.
Furthermore in pixels are weighed by distance to the current pixel in Weighed average mode. The further the tested pixel is away from the current pixel the less influence it has on the current pixel.
How much influence the pixels have in Weighed Average mode in a 5 diameter window.
Average Pixels:
Works almost similar to Donald Graft's Smart Smoother, except from the diamond check (described above) that should prevent some color blending on big diameters. Great for cartoons since it creates very evenly colored areas.
An example:
In this example all MPEG artifacts are removed while still retaining a clear image.
This mode has a Weighed with difference option, that preserved more structure. The theory behind this mode is, that even if a pixel passes under the threshold it will have less influence on the current pixel, depending on how close it is to reaching the threshold. This preserves more structure, while still smoothing out more evenly colored pixels.
Weighed with difference can be varied by using the Maintain Diffweight slider. This slider turns off "Weighted with difference" when the difference is below this threshold. This makes it possible to heavily blur soft noise on evenly colored surfaces.
Weighed average
Weighed average is more aimed at video sources - trying to provide a better solution for video sources. There are several new thing in this mode. First of all the blur does not produce even-colored surfaces. This happens since the actual pixel is less influenced by pixels far away. The further away the pixel - the less influence - even though it passes the threshold. This will ensure that shading (from one color to another) will be much more smooth that simple averaging.
There is two additional options. Most important is Weighed with difference. This mode adds a further weighing into the equation. The closer the color of the pixel is to the current one, the more it will be blended into the current pixel. That also means that the closer the difference is to the threshold, the less influence will it have on the current pixel. That means that almost identical pixels (usually due to noise/quantization errors) are blended much more (and thereby reduced) than pixels with greater differences. Weighed with difference has almost no perfomance impact.
An Example:
Weighed with difference - Threshold 30 - Diameter 7. Amount 254.
The second option available in this mode is Amount. It controls how much influence the filter maximum may have. This can be used for letter greater amount of detail do through while still maintaining a big threshold. A value of 128 ensures that the original pixel will always have at least 50% influence on the final pixel. This also has no impact on performance.
There is an option to Visualize Blur (thanks to Leuf for the idea), that shows how much the different parts of the image is blurred. This is very excellent for adjusting parameters.
An Example:
In pure white areas, the image is blurred to its maximum. In black areas there is no blurring at all.
Comparison:
This is an example to show the differences between the filter modes. Please note that the result is excaggerated - and that the filter is capable of increasing or decreasing the amount it blurs in all modes.
Original image
Average Pixels
Average Pixels & Weighed with difference
Weighed average
Weighed average & Weighed with difference
Notes:
- The filter has been made with maximum quality in mind - and at the sacrifice of speed. The filter has been opimized as much possible without sacrifizing quality. Use Average Mode without Weighed with Difference for maximum speed. If further speed is required, use the Optimized 2D-cleaner by Jim Casaburi and Jaan Kalda.
- The filter has been developed on AMD Athlon-processors, and the MMX code is heavily optimized for the Athlon pipeline, so AMD should be the way to go.
- The sources includes a custom build step that copies the filter (and symbolic information) to the Virtual Dub directory. If you would like this part to work, you should replace the paths in the Custom Build tab to reflect your Virtual Dub installation path.
- There are several compiler options available. Most notably is a "Precise average", that has even more precise rounding on averaging. This does not seem nessesary on the sources, since it will only have a +-1 RGB-value on the final result, and adds 3 more additions per pixel.
- SSE2 optimizations are quite obvious, and will probably give an even greater speed advantage, but I have no P4, nor any interest in buying one, but I'll be happy to assist anyone feeling up to the challenge.
- Check grayscale is always off in MMX versions. Use plain version if you need it.
Todo:
(Not ordered by importance - mail me if you have other requests or feel one area needs to have my full attention.)
- Implement YUV processing, so it is possible to only smooth luma or color areas. Perhaps implement different thresholds for luma/chroma.
- Do Avisynth YUV version. I actually usually use Gordian knot for DVD-backups myself. (Progressing - C-version 40% done)
- Check parameters - if invalid parameters are passed it could crash the filter.
- Implement interlaced input.
History:
V2.11
- New feature: Visualize Blur. Thanks must go to Leuf for showing me this excellent feature.
V2.1
- MMX optimized Average Pixels mode. Speedup in average mode is around 120% without Weighed with Difference. Without Weighed with difference the filter is now approximately 30-50% faster than Smart Smoother and Spatial Smoother, which both have very similar smoothing algorithms, but with a slight worse quality in most cases. Quality is 100% the same as older versions.
- Bug fix: Threshold was still wrong - would only trigger if ALL RGB values where above threshold. All users should upgrade.
- Minor optimization to weighed mode.
V2.01
- Bug fix: Differences in red color only did not trigger the threshold test.
- Plain and P3/K6-3 version where the same as the Athlon binaries, causing them to crash! :(
- Small optimizations to weighed mode.
V2.0
- Implemented Weighed with difference in Average pixels mode. Has great impact on quality (especially on anime), but will result in slowdown compared to ordinary Average pixels.
- Implemented variable weighed with difference. This option will make it possible to maintain unweighed blending up to a certain threshold (must be less than threshold). This option has no performance impact.
- MMX Optimized Weighed Average. Speed increase is approximately 30-50%. Three seperate versions are compiled:
- Athlon optimized version.
- K6, P3 & P4 MMX version.
- No MMX (integer) version.
MMX mode has slightly worse precision (15 bits weights, compared to 16-bit integer weights). May darken the image by a few RGB-values on big (>7) diameter settings.
- Bug Fix: "Weighed with difference" was not saved, when saving preferences. Therefore it was always on, when settings were loaded.
- Optimized (integer mode) memory usage, by requesting 32 bits at the time.
- Small optimizations to (integer mode) inner loops.
- Diameter defaults to 5.
- Cosmetic changes to GUI.
V1.1
- Optimized filter approximately 10 to 20%. (Storing temporary data in structs for cleaner cache usage and using pointers for pixel lookups).
- Removed Exact Raycheck from source.
- Removed Weighed Transparency from the code.
- Made it possible to compile a more precise version. This gives a minor slowdown, but it wont be visible unless you run the filter more than 10 to 20 times on the same material.
- When checking grayscale colors are weighed.
- Minor fixes and corrections.
V1.0
Download older versions:
[Download binaries] v2.01 (Athlon MMX optimized) (contains known bug)
[Download binaries] v2.01 (K6-III, P3, P4 MMX version) (contains known bug)
[Download binaries] v2.01 (No MMX version)
[Download source code] v2.0 (MSVC 6 + preprocessor pack 5). (contains known bug)
v1.1
[Download binaries] v1.1
[Download source code] v1.1
Other
Special thanks to Thomas Daniel for excellent feedback and help!
Also thanks to: Leuf, dividee, Acaila, TT, _Outpinged, -h, poopety poop, Rudolf Groß, Tøsen, VIC, Christian Senft, Avery Lee & Donald Graft for help, support, suggestions and other stuff this couldn't have been done without.
Contact
Contact Klaus Post at kp@interact.dk for bugs, suggestions, comments, etc...
New versions of the filter should be downloadable from Donald Graft's filter page.