SpotRemover filter for digital video cleaning
What is it?
Details
Performance
Example
People say...
FAQ
Code samples
Download
Introduction
SpotRemover is a filter/plugin for VirtualDub to clean noise in your digital video. It is designed for digital restoration of damaged films. SpotRemover filter removes (cleans) dust, hairs, specks and other defects commonly seen in aged films.
The filter also includes optional time smoothing to suppress film grain.
Besides VirtualDub, SpotRemover can also be called from AviSynth (see below).

News:
09/26/2013
Updated the set of libraries and sample scripts for cleaning old 8mm film captures.
You can download it here (2,139 kb).
03/26/2012
Here is the most optimal AviSynth script, which uses MVTools v.2 with SpotRemover:

LoadPlugin("F:\DGMPGDec\DGDecode.dll")
LoadPlugin("F:\AviSynth\plugins\mvtools2.dll")
LoadVirtualDubPlugin("F:\VirtualDub\plugins\SpotRemover.vdf","SpotRemover",11)

source = mpeg2source("F:\1\dv.d2v")
source
super = MSuper(pel=1, sharp=0)

b_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=4, overlap=2)
b_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=4, overlap=2)
f_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=4, overlap=2)
f_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=4, overlap=2)

bf2 = MCompensate(super, b_vec2)
bf1 = MCompensate(super, b_vec1)
ff1 = MCompensate(super, f_vec1)
ff2 = MCompensate(super, f_vec2)

interleave( bf2, bf1, source, ff1, ff2 )
ConvertToRGB32()
SpotRemover("SSI:0 SSC:-5 SKW:3 SLI:2 SLC:2 SLD:0 DLS:24 DLC:15 DPC:14 DSF:1 DSD:0 MTX:16 MTY:12 MTL:22 MDX:1 MDY:1 MIH:0","")
SelectEvery( 5, 3 )
ConvertBackToYUY2()
Trim(1,0)

#ColorYUV(gain_y=15, off_y=0, gamma_y=0, cont_y=0, gain_u=0, off_u=0, cont_u=0, cont_v=0)

#LanczosResize(720,544)

01/28/2011
Thanks to a request by Filip who was trying to clean his old 8mm films, I found a nice combination of filters that recovers the original progressive sequence with no duplicate frames (well, almost). This helps very much to the subsequent detection of spots by SpotRemover.
You can download examples of the AviSynth scripts with the original video sample, the one cleaned by SpotRemover, as well as the required filters here (2,139 kb).
10/15/2010
(version 3.5.6)
Updated the filter to enable processing of the HDTV 1080p material without problems.
03/11/2009
(version 3.5.5)
Fixed a bug that caused spontaneous crashes in the configuration dialog window.
The code is now compiled with Intel C++ Compiler for better performance.
01/02/2008
Added another example of the AviSynth script with SpotRemover filter (see 04/12/2007). Now there are two versions: one with temporal noise smoothing and one without.
If you also need to suppress the film grain, you should replace the line
interleave(...)
with this one:
interleave( bf2, bf1, SRC.MVDegrain2(b_vec2,b_vec1,f_vec1,f_vec2,plane=4,thsad=400,idx=1), ff1, ff2 )


And here is a couple of movie samples demonstrating the efficiency of restoration of the damaged films, even with an intensive motion. Each example has the original version (before filtering) and the filtered one.
(right-click on each image and select "Save target as" to download the AVI file)
Original movie SpotRemoved movie

Original movie SpotRemoved movie
09/24/2007
Added a brief explanation of the parameters that can be used in AviSynth script. An example of the script is shown below.

SSI - Smooth Strength Intensity
SSC - Smooth Strength Color
SKW - Smooth Kernel Width
SLI - Smooth Locking level for Intensity
SLC - Smooth Locking level for Color
SLD - Smooth Locking Debug
DLS - Detect Level for Spot detection
DLC - Detect Level for Clearance
DPC - Detect Perimeter Clearance
DSF - Detect Spot Fullness factor
DSD - Detect Spot Debug
MTX - Motion Table X (columns)
MTY - Motion Table Y (columns)
MTL - Motion Table Level to flag cells
MDX - Motion Distance X
MDY - Motion Distance Y
MIH - Motion Interrupted History
CBR - Color BRightness
CCO - Color COntrast
CSA - Color SAturation
CBA - Color Balance
CSR - Color Shift Red
CSB - Color Shift Blue
FCI - Frame Control Interlaced

04/12/2007
Here are two examples of the AviSynth scripts that combine MVtools with SpotRemover:

Spot removal and temporal smoothing at the same time:

LoadPlugin("F:\DGMPGDec\DGDecode.dll")
LoadPlugin("F:\AviSynth\mvtools.dll")

LoadVirtualDubPlugin("F:\VirtualDub\plugins\SpotRemover.vdf","SpotRemover",11)

SRC = mpeg2source("D:\Projects\reb.d2v")

FLT = SRC.Blur(1.58)
b_vec2 = FLT.MVAnalyse(isb = true, delta = 2, idx=1)
b_vec1 = FLT.MVAnalyse(isb = true, delta = 1, idx=1)
f_vec1 = FLT.MVAnalyse(isb = false, delta = 1, idx=1)
f_vec2 = FLT.MVAnalyse(isb = false, delta = 2, idx=1)
bf2 = SRC.MVCompensate(vectors=b_vec2, idx=2)
bf1 = SRC.MVCompensate(vectors=b_vec1, idx=2)
ff1 = SRC.MVCompensate(vectors=f_vec1, idx=2)
ff2 = SRC.MVCompensate(vectors=f_vec2, idx=2)
interleave( bf2, bf1, SRC, ff1, ff2 )

ConvertToRGB32()
SpotRemover("SSI:7 SSC:0 SKW:5 SLI:2 SLC:2 SLD:0 DLS:26 DLC:18 DPC:16 DSF:2 DSD:0 MTX:16 MTY:12 MTL:22 MDX:1 MDY:1 MIH:0","")
SelectEvery( 5, 4 )


Spot removal only (without temporal smoothing):

LoadPlugin("F:\DGMPGDec\DGDecode.dll")
LoadPlugin("F:\AviSynth\mvtools.dll")

LoadVirtualDubPlugin("F:\VirtualDub\plugins\SpotRemover.vdf","SpotRemover",11)

SRC = mpeg2source("D:\Projects\reb.d2v")

FLT = SRC.Blur(1.58)
b_vec2 = FLT.MVAnalyse(isb = true, delta = 2, idx=1)
b_vec1 = FLT.MVAnalyse(isb = true, delta = 1, idx=1)
f_vec1 = FLT.MVAnalyse(isb = false, delta = 1, idx=1)
f_vec2 = FLT.MVAnalyse(isb = false, delta = 2, idx=1)
bf2 = SRC.MVCompensate(vectors=b_vec2, idx=2)
bf1 = SRC.MVCompensate(vectors=b_vec1, idx=2)
ff1 = SRC.MVCompensate(vectors=f_vec1, idx=2)
ff2 = SRC.MVCompensate(vectors=f_vec2, idx=2)
interleave( bf2, bf1, SRC, ff1, ff2 )

ConvertToRGB32()
SpotRemover("SSI:0 SSC:-5 SKW:3 SLI:2 SLC:2 SLD:0 DLS:26 DLC:18 DPC:10 DSF:2 DSD:0 MTX:16 MTY:12 MTL:22 MDX:1 MDY:1 MIH:0 ","")
SelectEvery( 5, 3 )

12/21/2006
I found an interesting and efficient method of cleaining the old film dust by combining my SpotRemover filter with the MVTools package by Fizick. His filter does an excellent job at motion compensation, which greately simplifies the subsequent detection of spots by SpotRemover.
The result is quite impressive. Here is a quick look:

Original movie
Detected spots
Final picture

v.3.5.4
06/18/2003
Added support for interlaced video.
However, processing of telecined video is not recommended. Read F.A.Q.
Minimal kernel size (for smoothing) is reduced to 3 for a faster preview.
Fixed bug produced "illegal instruction" error on Cyrix(VIA) CPUs.
Fixed bug caused image shift when attempting to process odd width frames.
Fixed bug caused occasional memory crashes reported by a few users.
v.3.5.3
05/11/2003
Fixed bug with switching "Interrupted motion history" flag from script files.
Fixed bug when the last spot in the motion history chain was not marked moving while "Interrupted motion history" was set.
Fixed bug with the display of percentage of saturated pixels when preview is turned off.
v.3.5.2
05/04/2003
Added a checkbox in "Color" tab to bypass color correction for Preview.
Added "percentage of saturated pixels" to help finding the optimal color correction settings.
No more time lag in preview window when changing frames.
The effect of Brightness, Contrast, and Saturation sliders is doubled.
Fixed compatibility issue with Hue/Saturation/Intensity filter.
v.3.5.1
03/19/2003
Since this release, SpotRemover.vdf module contains all three versions of the code with different level of optimization:
1) MMX instructions;
2) MMX and CMOVxx instructions;
3) MMX, CMOVxx, and integer SSE instructions.
The appropriate code is automatically activated at startup based on CPU detection. The optimization level is reported in VirtualDub's list of filters.
Now pixels in a spot are replaced by default with the average of the previous and the next frames.
In script files, it is possible to specify which frame to use (previous, next or the average of both).
Fixed problems with dialog metrics at different system font sizes.
Fixed the crash on the dialog startup at certain conditions.
v.3.5.0
03/14/2003
New configuration options for "Basic" setup.
New checkbox to allow interrupted history of spot's motion tracking.
New color control: "Saturation Balance".
Preview window has no more time lag during color adjustments.
New "tabbed" interface.
Tab switching shortcut keys: Ctrl-(Shift)Tab or Ctrl-PgUp/Dn.
If shown, the Help window is synchronized during the tab switching.
Input focus is automatically restored to the last used Tab and Control.
Help pop-ups are invoked by mouse hovering.
All configuration parameters can be changed from script files.
Script files may have comments (lines not beginning with a number).
The format of the configuration strings of VirtualDub's VCF and JOBS files has changed. Old format is still supported. To use your old VCF and JOBS files you only need to replace the line
VirtualDub.video.filters.Add("SpotRemover (3.4.2)");
with
VirtualDub.video.filters.Add("SpotRemover (3.5)");
03/12/2003

FAQ updated. Added topics about processing interlaced sources and 8-mm film captures.

v.3.4.2
01/26/2003
Motion distances are now input as percents of the frame size.
Added new mode for script file to change main parameters of the spot removal at specified frames.
Fixed the case when restoring defaults resulted in the lost script file name.
Minor optimizations in spot detection routine.
v.3.4.1
01/24/2003
Maximal amount of spots per frame is now 96 (was 48).
Smoothing module was rearranged. Now the Kernel width can be as low as 5 (was 9) for faster processing or debugging.
Rounding in integer division is now more correct (from viewpoint of math). Its accuracy is about 0.4 of intensity step (which is 0...255). The drawback is that MMX_Only and the MMX+SSE versions do not produce identical results (MMX_Only uses special tricks to implement unsigned multiply, see below 2.0.1).
Spots within the cell with motion (or just touching its edge) are now marked as moving.
Motion table size increased to 24x18 (was 14x10). Optimized processing of the motion table. Optimized intensity difference comparison.
Added new modes for script files to change motion threshold and color controls at specified frames.

See also History of older versions.
VirtualDub filter for digital video processing for clear and clean noise smoothing removal. Remove dust, spots, blots, scratches, speckles, hairs - SpotRemover!


What you think about this filter?    E-mail me at

© 2002-2014. Konstantin Khlopenkov




How to make a good DVD rip.