13 Removal of clicks and scratches

13.1 Introduction

Problems in transmission (electronic broadcast) or media storage/handling can lead to artefacts, which will be discussed here.

The electronic images are transferred via electromagnetic waves. This suggests that if we are producing waves with a spectrum close to that broadcasted by a transmitter, interference will be introduced in the original broadcast signal. But this isn't something we should be afraid of, as such intentional disturbances are forbidden by law in many countries. However,it turns out that electromagnetic waves (EM-waves) produced by a mere lightning or electric sparks (amongst other things) emit a wide spectrum of EM-waves, some of which intrude into our broadcast spectrum. So this results in clicks (different words for this effect are sparklies, spots) on our screens. We know that this won't destroy the signal completely, as there are very slim chances that such disturbances will cover the complete bandwidth that is use. They will only bite our signal here and there. Perhaps you noticed last time somebody used a hair-dryer while you were watching plain old analogue tv broadcast.

An other source of such problems is seen in analogue satellite tv. Here, worsening of the signal/noise (s/n) ratio results in the sparklies (in a simillar fashion as your am-radio has much noise, because the transmitters are too far away, and am is prone to interference), so when you have heavy rain-fall, clouds are blocking your antenna's view of satellite and you have worse s/n ratio, thus more sparklies. This will also happen if a particular transmitter on the satellite (also called 'transponder') is transmitting on lower power than others-in such case that channel has more sparklies than other (higher power) transponders. So in a sense, more sparklies means you have a signal that gets closer to white noise itself (lowering s/n means getting closer to noise).

VHS knows of this problem mainly by means of poor tracking adjustment. (This can also be considered as a kind of noise, namely noise induced by misaligned scanning (on playback) of magnetic video-tracks layed on tape during the recording.) VHS will also record any noise that it sensed in the 'air' (already explained interference of EM-waves), as vhs is just recording what the antenna provides. Usually though, vhs doesn't have a means to produce this sort of noise if your signal (to be recorded) is clean and tracking is OK.

In general, it can be said that digital systems are more robust than analogue ones, so DVB broadcast (for example) is harder to 'jam' (with some sort of EM noise) than analogue broadcast. This is because digital systems can still differentiate 0 from 1's even if you have very high levels of noise in between. However, digital broadcasting systems suffer from other things. (Mainly because too much channels are packed into a small overall bandwidth. Then it becomes apparent how 'line noise' of analogue broadcast (unrelated to clicking etc.) is actualy better and less visible than low-bitrate 'blocking noise' of digital mpeg systems.)

Film image flaws take much less time to explain. It's just damage/deterioration/covering (with foreign objects) of the negative or positive film media. This is essentially caused by the mechanics that drag the film over the image making/projecting machinery. Also, if camera's insides is filled with dust, then dust will block a part of the path of the light onto the film. (That goes for the negative->positive conversion process too. Positive is the film that goes to cinemas, but also sometimes it's used to make electronic video if the negative can't be found.)

Vertical scratches are typically from the mechanism inside a projector or even a crappy film camera. Probably, you have seen these a lot on old films on TV.

This guide explains an attempt to make such flaws less irritating. Regrettably, there exist no free VirtualDub plugins which attempt to remove those artefacts.

13.2 AviSynth usage

The Despot plugin (by fizick) will be used here for clicks/speckle removal, since it is the only good filter available.

The spots should be removed before the deinterlacing process (or before any additional filtering if the source is progressive). The filter requires YV12, so you should convert to that color format before using it.

ConvertToYV12(interlaced=true)
Despot(..., interlaced=true)
Deinterlace(...)

To set the correct settings, you should do the following steps:

0 - interlaced setting:
If your video-to-filter is interlaced, then "interlaced=true" should be selected, otherwise set it to "false". Interlaced processing works on fields, so "pheight" should be halved (ie if you measured 4 pixels, you should enter 2 if interlaced mode is used). If you see horizontal stripes in your video, like this

vhs-source1line

or this

vhs-source1line-1

try setting "pwidth" to full frame width (768, 720, 704 or whatever your capture size was), so the detection (more about this in point 3) shows something like this

vhs-despotmark1line

or this

vhs-despotmark1line-1

1 - "pwidth" and "pheight":
Set "pwidth" and "pheight" slightly bigger than the dimensions of the specks you want to remove (you can copy-paste the speckled frame from VirtualDub to some image viewer or even a mere "paint" (to copy input frame in vdub <Ctrl+1>), and measure the speck by selecting it with paint's "select" (rectangular).

2 - m, p1, p2 parameters:
Input some values for "m" (motion) and p1, p2 parameters, for example

DeSpot(p1=30, mthres=15, p2=10, pwidth=12, pheight=10, mwidth=12, mheight=10, interlaced=false, blur=4)

The author of the plugin suggests "p1 > mthres > p2", so use it as a decent starting point.

3 - "DeSpotMark":
Be aware of what are you doing. If you turn on "DeSpotMark", like this

DeSpotMark(p1=30, mthres=15, p2=10, pwidth=12, pheight=10, mwidth=12, mheight=10, interlaced=false, blur=4, mark_v=255)

It will show the recognized spots as white speckles (the recognized spots are the ones that'll be removed).

4 - p1, mthres and p2 settings:
Try to find good settings; p1, mthres and p2 settings are the most important settings of this filter. They steer what portions of image are rated as "dot to be removed" and what "good portion of the image, leave as-is". This will probably takes some time and many openings of the script in VirtualDub.

You want to remove as much of junk as possible while not disturbing good portions of the image too much. Thus you need to toy with p1, mthres and p2. When you see too much of whiteness applied, you know you're doing too much of interpolation. The goal is to affect the spots only. (Meaning that the white areas only cover the real spots. Open raw video in one instance of VirtualDub, and despot filtered in another, so you know exactly what's happening.)
If p1, mthreash and p2 tweaking doesn't satisfy, you can also try changing the "mwidth" and "mheight", although five variables to balance with is a difficult job.

Generally, it can be said that higher values of p1 and p2 will denoise less (less interpolation going on), while higher values of mthresh results in more denoising. Higher values of mheight and mweight will denoise less.

5 - mark setting:
Turn off 'mark' by erasing that word from syntax. The last thing to do is checking unprocessed video (from one VirtualDub instance) versus processed one: does it look acceptable? 

Few final notes. We tried to do vhs drop-out fixing with this filter, but we had less luck with it. It seems that vhs drop-outs are too gentle for despot to find. The examples in

vhs-source1line

are not a drop-outs in this sense. The usual vhs drop-outs are lines with totally messed color info and a minor and less sudden degradation of luma signal. Despot searches for abrupt discontinuations in luma plane.

Another shortcoming of this filter is a handling of motion scenes: filter that works with image data can't really tell if it was just a speckle in a single frame or was it subject moving. Look, for example, at how despot interpolated the buttons here

processed_frame5206[buttons]

while it shouldn't of touched anything 

unprocessed_frame5206[buttons]

Usually, it will just turn itself off when it senses faster camera motion. But generally, you can tweak a filter so that no bigger problems occur. Be also warned that filter is pretty slow (12 fps encoding speed dropped to 6 fps when despot was turned on).

Afterwards proceed as described in the AviSynth post processing guide.

References:
despot (by fizick) home
ctmedian/despot thread on doom9
kevin anderson's ctmedian: (despot is derived from this filter)
ctmedian doing a good job on removing analogue satv sparklies


Back to VirtualDub postprocessing

Back to AviSynth postprocessing

Back to the Index: HOME


Last edited on: 06/12/2004 | First release: n/a | Author: Ivo | Content by doom9.org