Vapoursynth RemoveDirtMC

From wiki.selur.net
Jump to navigation Jump to search

RemoveDirtMC is the motion-compensated form of RemoveDirt: it removes film dirt and spots after warping the neighbor frames onto the current one, so the cleaning holds up better in motion.

Filtering → Vapoursynth → Artifacts

RemoveDirtMC controls in Hybrid
RemoveDirtMC controls in Hybrid

What it does

Motion vectors are searched on a copy whose luma is slightly blurred. With them the previous and the next frame of the untouched clip are warped onto the current frame. The three frames are put in a row and the RemoveDirt chain runs on them (temporal clean, scene change selection, repair, block-wise motion detection, final RemoveGrain); only the middle frame is kept. Single-frame dirt is replaced, real motion is restored.

Requirements

  • The GPU option needs SVP (the SVPflow libraries); without it the option is disabled.

Settings

Control Parameter Range / values Hybrid default Meaning
Limit limit 0 – 255 6 Noise level of the motion detection: pixel differences up to this value are ignored. Higher means fewer blocks count as motion, so more of the frame gets the temporal clean.
Repair mode repmode 0 – 24 16 Repair mode used to limit the cleaned frame against the source, for luma; both chroma planes use mode 1.
RemoveGrain mode remgrainmode 0 – 24 17 Mode of the final RemoveGrain pass on luma; both chroma planes use mode 1.
Block size block_size 8, 16, 32 8 Block size of the motion search.
Block overlap block_over 0, 2, 4 4 Block overlap of the motion search.
GPU gpu on/off off Uses SVP for the motion compensation instead of the MV plugin.
Tools: MV – mvgpu, mvutensils, mv mvgpu with a discrete GPU, else mvutensils Motion vector implementation; not used with the GPU option.
Tools: RG – zsmooth, neo_smo zsmooth RemoveGrain/Repair/Clense implementation.
Tools: RemoveDirt – removedirt removedirt RemoveDirt plugin.

Example

Default settings on a 10-bit YUV 4:2:0 source (machine with a discrete GPU):

# adjusting color space from YUV420P10 to YUV444P16 for vsRemoveDirtMC
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
# denoising using VsRemoveDirtMC
clip = removeDirt.RemoveDirtMC(clip, tools={'mv': 'mvgpu', 'rg': 'zsmooth', 'removedirt': 'removedirt'})

How Hybrid calls it

  • RemoveDirtMC works on 8-bit and 16-bit YUV 4:2:0, 4:2:2 and 4:4:4; other formats are converted first. With GPU on, the clip is converted to 8-bit 4:2:0, which SVP needs.
  • Values are only written when they differ from the defaults; Hybrid's defaults equal the script's. gpu=True is only written when the option is on and SVP is available. The Tools choice is always written.
  • Limit is not scaled: the plugin treats it on the 8-bit scale at every bit depth.
  • The motion search uses pel 2 and true motion. On the SVP path the frames are interpolated with SVP and brought back to the source frame rate; the overlap is mapped to SVP's overlap levels.
  • RemoveDirtMC also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

As in the AviSynth original, the blur (RemoveGrain mode 12 on luma) is only used to steady the vector search; the compensation and the cleaning work on the unblurred clip. The fixed motion detection values are the same as in RemoveDirt (70 % for a scene change, distance 1, mode 2, 12 noisy pixels).

The plugin

RemoveDirt was written by Rainer Wittmann (kassandro) for AviSynth; Ferenc Pinter's port adds more color formats, 10 – 16 bit and, since version 1.0, VapourSynth support, with thresholds that do not depend on the bit depth.

Sources