From Avisynth wiki
Jump to: navigation, search
Author Fizick
Version v1.1.0
Download DeScratch110.7z
Category Film Restoration
License GPLv2
Discussion Doom9 Forum



This plugin removes vertical scratches from films. Also it can be used for removing of horizontal noise lines such as drop-outs from analog VHS captures (after image rotation).


Syntax and Parameters

descratch (clip, int "mindif", int "asym", int "maxgap", int "maxwidth", int "minlen", int "maxlen", float "maxangle", int "blurlen", int "keep", int "border", int "modeY", int "modeU", int "modeV", int "mindifUV", bool "mark", int "minwidth", int "left", int "right")

clip   =
Input clip.

int  mindif = 5
Minimal difference of pixel value in scratch from neighbours pixels for luma plane.
Range: from 1 to 255, default 5

int  asym = 10
Maximal asymmetry of neighbors pixels
Range: from 0 to 255, default 10

int  maxgap = 3
Maximal vertical gap to be closed.
Range: from 0 to 255, default 3

int  maxwidth = 3
Maximal scratch width.
Range: odd numbers from 1 to 15, default=3

int  minlen = 100
minimal scratch length, (default = 100).

int  maxlen = 2048
Maximal scratch length, (default = 2048).

float  maxangle = 5.0
Maximal angle to vertical (in degrees, default = 5.0).

int  blurlen = 15
Radius of vertical blur for frame analysis (default = 15).

int  keep = 100
Percent of scratch detail to keep (default = 100).

int  border = 2
Thickness of border near scratch for partial restoration (default = 2).

int  modeY = 1
Processing mode for luma plane (0 - no, 1 - low(black), 2 - high(white), 3 - both, default=1).

int  modeU = 0
Processing mode for chroma U plane (0 - no, 1 - low(green), 2 - high(red), 3 - both, default=0).

int  modeV = 0
Processing mode for chroma V plane (0 - no, 1 - low(yellow), 2 - high(blue), 3 - both, default=0).

int  mindifUV = 0
Minimal difference of pixel value in scratch from neighbours pixels for chroma planes.
Range: from 0 to 255, default 0:
  • if = 0, then internal mindifUV value is same as mindif.

bool  mark = false
Mark scratch in debug mode (true or false, default = false).
(set rejected extrems pixels to grey, set scratches pixels to white or black)

int  minwidth = 1
Minimal scratch width.
Range: odd numbers from 1 to 15, default=1

int  left = 0
Left margin of processing window (inclusive), default=0.

int  right =
Right margin of processing window (exclusive), default=frame width or 4096.

Parameters maxgap, maxwidth, minwidth, minlen, blurlen, border, left, right should be given in pixels.

How It Works

The plugin firstly detects scratches, then removes them.
It uses spatial information only from current frame.
I adapt it to restoration of my old 8 mm films, may be it will be useful to somebody else.

Scratch detecting

Apply some vertical blur to frame copy, for suppression of image thin structure, inclined lines and noise.
Search for local extremes of luma in every row with luma difference criterion for scratches with width not above a max.
Put these extremes in some map (frame). Search and deactivate extrems for width below a min (optional).
Optionally close vertical gaps in extrems by vertical expanding of extreme points.
Test the extremes map with length and angle criterions, so select real long scratches only.

Scratch removing

Scratches may be either partially transparent, smooth (with image details), or opaque (with no details or almost destroyed).
In the first case, plugin can subtract smooth (blurred) part of luma scratches variation from original image. Therefore, image details are kept.
In the second case, plugin replaces scratched pixels by mean luma values from some neighbours pixels (in same row).
We have also intermediate case by setting some percent of detail to keep.
In all cases, some nearest neighbours pixels may be also partially changed for smooth transition.


descratch default settings:

descratch ()

You MUST tune parameters for your video.
Use AviSynth commands Greyscale(), UtoY(), VtoY(), and mark parameter for debug and tuning.

Archived Downloads

Version Download Mirror
v1.1.0 (x86/x86) DeScratch110.7z DeScratch110.7z /// MediaFire

External Links

Back to External Filters

Personal tools