Vapoursynth Cnr4

From wiki.selur.net
Revision as of 09:48, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Cnr4 is a temporal chroma denoiser modelled on the old Cnr2. It works well on stationary rainbows and heavy analog color noise, for example from VHS.

Filtering → Vapoursynth → DeNoise

Cnr4 controls in Hybrid
Cnr4 controls in Hybrid

What it does

Each pixel is compared with the same pixel in the neighbor frames. Where the difference is small (noise rather than motion) the frames are blended; where it is large the pixel is left alone. Unlike Cnr2, Cnr4 looks at past and future frames, runs multithreaded and ghosts less. A scene change detection keeps it from blending across cuts.

Settings

Control Parameter Range / values Hybrid default Meaning
Mode Y/U/V mode wide, narrow wide / narrow / narrow Wide reacts less to pixel changes and denoises more; narrow keeps more detail.
Sense Y/U/V sense 0 – 255 35 / 47 / 47 Noise/motion threshold; higher catches more noise but also more motion (ghosting).
Strength Y/U/V str 0 – 255 192 / 255 / 255 Strength; higher denoises more and risks artifacts.
Pow Y/U/V pow 0 – 10 1.00 Exponent of the weight curve; above 1 denoises more, below 1 less. Lowering it is a good way to get rid of artifacts.
Radius radius 1 – 10 2 Frames on each side.
TMode tmode 0 – 4 0 Temporal weighting: 0 inverse difference; 1–4 Cnr2-style modes (3/4 much slower); higher modes keep more detail. Only with a radius above 1.
WMode wmode 0 – 3 0 Frame weighting: 0 equal, 1 square root, 2 sine, 3 linear; higher modes are weaker. Only with a radius above 1.
Scene change + threshold scenechange on/off, 0.1 – 100 % on, 10 % Detects cuts first; Cnr4 does not blend across them. Without it, artifacts appear at cuts.
Tools: Cnr – zsmooth, neo_smo zsmooth Plugin that provides Cnr4; both give the same result.
Tools: SCD – scd, misc, std, mv scd Scene change detection; with mv the motion vector thresholds are used instead of the percentage.

Example

Default settings on a 10-bit YUV 4:2:0 source:

# chroma denoising using Cnr4
clip = misc.SCDetect(clip, threshold=0.1, tools={'cnr': 'zsmooth', 'scd': 'scd'})
clip = core.zsmooth.Cnr4(clip)

How Hybrid calls it

  • Cnr4 works on 8–16-bit integer YUV; other formats are converted first.
  • With Scene change a detection step runs first and marks the cuts in the frame properties; the threshold is written as a fraction (10 % = 0.1).
  • Values are only written when they differ from the defaults; Sense, Strength and Pow as a list of three when one plane differs.
  • Sense and Strength are passed on the 8-bit scale; the same values gave the same chroma effect at 8, 10 and 16 bit in Hybrid's tests.
  • Cnr4 also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

zsmooth

zsmooth's documentation calls the defaults aggressive. A cleaner luma helps (for example a prefilter passed as reference clip, which Hybrid does not offer). To weaken the effect it suggests raising TMode and WMode first and then fine-tuning Sense, Strength and Pow; for Cnr2-like results TMode 2 with scene detection at 0.1. neo_smo offers the same function, also for AviSynth+.

Sources