DeSpot
From Avisynth wiki
(Difference between revisions)
m (→Requirements) |
m (→Requirements) |
||
Line 18: | Line 18: | ||
* [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6] | * [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6] | ||
* [x64]: [[AviSynth+]] | * [x64]: [[AviSynth+]] | ||
− | *Supported color formats: | + | *Supported color formats: [[YV12]] |
<br> | <br> | ||
Revision as of 01:58, 2 June 2020
Abstract | |
---|---|
Author | Kevin Atkinson , Fizick |
Version | 3.6.1.1 |
Download | DeSpot3611.7z |
Category | Film Restoration |
License | GPLv2 |
Discussion | Doom9 Forum |
Contents |
Description
This filter is designed to remove temporal noise in the form of dots (spots) and streaks found in some videos. The filter is also useful for restoration (cleaning) of old telecined 8mm (and other) films from spots (from dust) and some stripes (scratches).
The plugin is based on Conditional Temporal Median Filter v.0.93 by Kevin Atkinson.
- See official documentation: http://avisynth.org.ru/despot/despot.html
Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: YV12
Syntax and Parameters
- DeSpot (clip, int "mthres", int "mwidth", int "mheight", int "merode", bool "interlaced", bool "median", int "p1", int "p2", int "pwidth", int "pheight", bool "ranked", int "sign", int "maxpts", int "p1percent", int "dilate", bool "fitluma", int "blur", int "tsmooth", int "show", int "mark_v", bool "show_chroma", bool "motpn", int "seg", bool "color", int "mscene", int "minpts", clip "extmask", bool "planar")
- clip =
- Input clip.
- clip =
- int mthres = 16
- A pixel needs to be different from the another frame by at least 'MTHRES' in order to be considered moving. This number should be larger than 'P2' in order to prevent noise from being identified as motion.
- int mthres = 16
- int mwidth = 7
- int mheight = 5
- These define the width and height of block for motion map denoising algorithm (erode and dilate stages).
- int mwidth = 7
- int merode = 33
- These define a threshold value of percent of motion pixels in the block at erode stage.
- int merode = 33
- bool interlaced = false
- Whether to treat the video as interlaced or not (progressive). The default is false (progressive) for DeSpot since version 1.3. (In older versions, the Field based video was processed as interlaced by default - it was a bug).
- bool interlaced = false
- bool median = false
- The filter may work in 2 main modes:
- false - Spots removing mode - filter will attempt to identify noise and eliminate it.
- true - Simple Median mode - filter will apply a simple temporal median filter to the non-moving areas of the image.
- The filter may work in 2 main modes:
- bool median = false
- int p1 = 24
- int p2 = 12
- A pixel needs to be at different from its neighbors by at least 'P1' in order for it to be considered noise. The surrounding pixels must be different by at lease 'P2' in order for the pixel to be considered part of the same spot.
- int p1 = 24
- int pwidth = 6
- int pheight = 5
- A spot can be no larger than pwidth x pheight.
- int pwidth = 6
- bool ranked = true
- Enables ranked ordered difference spot detector with 6 points instead of 2.
- bool ranked = true
- int sign = 0
- Set mode for removing of only black or white spots or both:
- sign = 0 - any spots and outliers (default)
- sign = 1 - only black (dark) spots and outliers
- sign = -1 - only white (light) spots and outliers
- sign = 2 - only black (dark) spots, any outliers
- sign = -2 - only white (light) spots, any outliers
- Set mode for removing of only black or white spots or both:
- int sign = 0
- int maxpts = 0
- Set upper limit of points (pixels) per every spot.
- Range: from 0 to 10000000, default=0 - no limit
- int maxpts = 0
- int p1percent = 10
- Set lower limit of relative fracture of high-contrasted (by criterion P1) pixels per spot (in percent).
- Range: from 0 to 100
- int p1percent = 10
- int dilate = 1
- Set range of morphological dilate (growing) of removed spots (in pixel units).
- Range: from 0 to 255
- int dilate = 1
- bool fitluma = true
- Enables some frame luminosity correction in places of deleted spots.
- bool fitluma = true
- int blur = 1
- Value (length) of local spatial blur near borders of deleted spots
- Range: from 0 to 4, default 1
- int blur = 1
- int tsmooth = 0
- Control temporal smoothing in static areas (except spots and motion).
- Set approximate threshold of pixel luma variance in 3 frames,
- The more variance exceed this threshold, the less temporal smoothing.
- 0 - no temporal smoothing.
- Range: from 0 to 127
- int tsmooth = 0
- int show = 0
- To instead spots removing, show a motion map and noise that would of been eliminated, use parameter:
- 0 - not show,
- 1 - to highlight the noise instead of removing it
- 2 - show a motion map and noise
- If
show=2
, the luma is changed as follows:- 255 (White): Noise that will be removed
- 159: Noise that won't be remove because it might be motion
- 95: Motion map for the current image
- To instead spots removing, show a motion map and noise that would of been eliminated, use parameter:
- int show = 0
- int mark_v = 255
- Where
mark_v
is the luma value to highlight the noise with. - The color (pink, green or grey) of noise spot now is depend from parity of
mark_v
. - Motion map is also shown.
- Range: from 0 to 255
- Where
- int mark_v = 255
- bool show_chroma = false
- Use to show clip color data on motion map.
- bool show_chroma = false
- int motpn = true
- Define motion detecting method.
- false - detect motion from previous to current and from current to next frame (old method used in all versions before 3.0)
- true - detect motion from previous to next frame (new method since version 3.0)
- Define motion detecting method.
- int motpn = true
- int seg = 2
- Control spots segments removing method.
- 0 - remove only spots pixels which has no overlap with motion zones (old method used in all versions before 3.0, most strong removing);
- 1 - remove only spots line segments which has no any overlap with motion zones;
- 2 - remove only whole spots which has no any overlap with motion zones (most safe).
- Control spots segments removing method.
- int seg = 2
- bool color = false
- Control color correction at place of removed spots .
- true - change color of pixels at places of removed spots to mean value previous, current and next frames,
- false - not change color of pixels at places of detected spots.
- Control color correction at place of removed spots .
- bool color = false
- int mscene = 40
- Set percent of pixels in motion for scenechange detection and disabling of frame spot removal.
- Range: from 0 to 100
- int mscene = 40
- int minpts = 0
- Set lower limit of points (pixels) per every spot.
- Range: from 0 to 10000000, default=0 - no limit
- int minpts = 0
- clip extmask = none
- Optional external mask clip. It will be binarized with threshold 127 and logically added (by "OR" operation) to internal motion mask. It can be used for additional protection of good objects (if you have some reliable mask).
- clip extmask = none
- bool planar = False
- Old hack, do not use. Read included docs if you are curious.
- bool planar = False
Tuning The Parameters
In order for the filter to work right the various parameters MUST be set correctly. There is no good default values.
- The first parameter that needs to be set is
interlaced
, set it to true if your video is interlaced, false otherwise.
- Than
pwidth
andpheight
need to be set. Set these to be slightly larger than the specks you want to eliminate. If your video is interlaced than height represents the height of an individual field. Thus, it will essentially be doubled.
- Than
p1
,p2
, andmthres
need to be set. In general,p1
>mthres
>p2
. If these are set too low than you may lose detail as small pixel variations might be mistaken as specks, thus losing detail, and more importantly, real specks might not be recognized as the size of the filter thinks the spec is might be larger thanpwidth
bypheight
.show=1
or 2 might be helpful in setting these parameters.
- The
mwidth
,mheight
parameters define the range of motion zones influence on noise (spots) zones. For decreasing of false spot detecting for fast motion scenes, you may increase these. After that, to cancel the influence of very small motion zones, you may increase themerode
parameter (relative) .
- Then
sign
may be set, if almost all spots are only white or only black. Correct tuning reduces number of false spot detection and artifacts.
- I recommend to use new parameter
ranked=true
for stability of spots detection in noisy video.
- Use parameter
maxpts
as another method (in addition topwidth
andpheight
) to avoid cleaning too large objects - probably not spots.
- Use
p1percent
to not clean weak (small contrast) spots with small relative fracture of strong points (withp1
threshold).
- For better removing of partially damaged pixels near non-sharp spots edges, you may increase spots sizes by increasing of
dilate
parameter.
- Enable brightness correction in spaces of deleted spots by parameter
fitluma
.
- This correction is local (line segment based) in
seg
>0 mode and must be used with properly defined dilated spots to prevent false correction due to non-sharp spots edges.
- To reduce noticeability of some borders in places of deleted spots some more, tune local spatial smoothing by parameter
blur
.
- For denoising of almost static areas, try to use temporal smoothing, with
tsmooth
parameter about 4-8.
- If spots have some color, try enable
color
parameter to correct spots color.
- To prevent artifacts at scene change, decrease
mscene
parameter.
- You also may try to use external mask clip (
extmask
parameter) in addition to (or instead of) internal motion mask to protect good objects. For example, it can be motion mask or inverted SAD mask from MVTools plugin.
How It Works
The filter works in Denoise mode as follows:
- 1a) Find pixels that are different from its neighbors by at least p1.
- If ranked parameter is true (new method from version 1.2), the 3 neighbors in previous frame (x-1, x, x+1) and same 3 neighbors in next frame are ranked (ordered by value), and those min and max are used for luma difference calculation for current pixel (x).
- If ranked parameter is false (old method), the only 1 neighbor in previous frame (at same position x) and 1 neighbor in next frame are used for min and max calculation,
- If sign parameter is not 0, the sign of difference is also taken into account.
- These pixels are merged to horizontal line segments.
- Stacked line segments are merged to spots.
- 1b) Enlarge outliers based on difference p2<p1.
- 2a) Determine the size of the specks and reject (will not clean) all those larger than pwidth x pheight.
- If numpts parameter is set, the big spots are rejected also.
- If p1percent parameter is set, then weak (by criterion p1) spots, which mostly consist of outliers (by criterion p2), are rejected also.
- 2b) If Dilate mode set, than spots are dilated to cover its non-contrast edges and close small gaps between its, by applying a morphological dilate operation to noise (spots) map.
- 3a) Find moving areas of an image by simply comparing each pixel to the another frame and considering all those which are greater than mthres.
- If motpn=false, it is defined from previous to current frame,
- if motpn=true, it is defined from previous to next frame.
- 3b) Mark motion pixels without noise with weight 3 in the motion map.
- If motpn=false, mark pixels determined both noise and motion as weight 1 in the motion map.
- 4) Denoise the motion map by constrained erosion and then dilating (as a whole it is morphological opening operation).
- During erode phase, the motion map is eroded with range mwidth/2 and mheight/2, and zones with small summary weight (less than 3*merode/100) are decreased or completely removed from motion map. Such zones correspond to small relative (in percent) numbers of motion neighbors within this range (or mostly noisy pixels -spots).
- During dilate phase, remained motion zones are enlarged with same range. These are probably the most important steps (especially for motpn=false) .
- 4a) If percent of pixels in motion is more than mscene parameter, the plugin detects scenechange, and whole motion map is set as motion.
- 4b) Add optional external mask to motion mask.
- 5) Only remove the specks in which there was no motion (in the current frame or next frame if motpn=false).
- In pixel removing mode (seg = 0), test and reject all noise candidate pixels which has overlap with motion zones, rest candidates will be removed.
- In segment removing mode (seg = 1), test and reject all noise candidate segments which has any overlap with motion zones, rest segments will be removed.
- In segment removing mode (seg = 2), test and reject all noise candidate spots which has any overlap with motion zones, rest spots will be removed. It is the most safe mode, with minimum artifacts false removing
- 6) Optional make luma correction in place of removed pixels and spatial smoothing near spot edges.
- 7) Optional make temporal smoothing of static areas.
- 8) Optional correction of color at place of spots.
The filter can also be configured to work as follows (Simple Median mode):
- 1) Find moving areas of an image by simply comparing each pixel to the previous frame and considering all those which are greater than mthres.
- 2) Denoise the motion map by erosion and then dilating (i.e. morphological opening). This is probably the most important step.
- 3) Apply a simple temporal median filter on the non-moving areas of the image.
Examples
DeSpotwith default settings:
AviSource("Blah.avi") DeSpot()
Archived Downloads
Version | Download | Mirror |
---|---|---|
v3.6.1.1 | DeSpot3611.7z | DeSpot3611.7z /// MediaFire |
v3.6.1.0 | despot3610.zip | despot3610.zip |
- v3.6.1.1 modified by Groucho2004.
External Links
Back to External Filters ←