Vapoursynth NNEDI3 Resize

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

NNEDI3 Resize enlarges the picture with the nnedi3 neural-network edge interpolator by a power of two and then fits it to the exact target size with a conventional kernel. It gives clean, non-jagged edges when upscaling and is the default method of the Resizer.

Filtering → Vapoursynth → Frame → Resize

NNEDI3 Resize controls in Hybrid
NNEDI3 Resize controls in Hybrid

What it does

nnedi3 doubles the size by predicting the missing pixels from a neighborhood with a small neural network; the horizontal and the vertical pass are done one after the other, and the half-pixel shift this causes is corrected. This is repeated until both dimensions reach at least the target (2×, 4×, …). The Downsizer kernel then scales to the exact size.

Settings

Tick Resizer and pick NNEDI3 as method.

Control Parameter Range / values Hybrid default Meaning
Neighbourhood nsize 8x6, 16x6, 32x6, 48x6, 8x4, 16x4, 32x4 8x6 Size of the area the network looks at.
Neurons nns 16, 32, 64, 128, 256 128 Network size; more neurons are slower and more accurate.
Network qual 1 – 2 2 Number of blended predictions; 2 is recommended for enlarging.
Training etype minimize absolute error, minimize squared error absolute error Weight set the network was trained with.
Prescreening pscrn old, new new Prescreener that decides which pixels need the network; the rest is interpolated simply.
Optimize opt on/off on Uses SIMD code; only for CPU implementations.
Downsizer kernel point, rect, linear, cubic, lanczos, blackman, blackmanminlobe, spline36, spline64, spline144, spline, gauss, sinc spline64 fmtconv kernel for the final fit to the target size (spline144 = spline with 6 taps).
Tools: NNEDI3 – znedi3, sneedif, nnedi3vk, vszipcu znedi3 Implementation: znedi3 (CPU, all settings), sneedif (OpenCL), nnedi3vk (Vulkan), vszipcu (NVIDIA CUDA); a Device field appears for the GPU ones.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356), resized to 1280x712:

# resizing using ZNEDI3
# current: 640x356 target: 1280x712
clip = edi_rpow2.nnedi3_rpow2(clip, rfactor=2, qual=2, tools={'nnedi3': 'znedi3'}) # 1280x712

How Hybrid calls it

  • The factor is the smallest power of two (at least 2) that makes both dimensions reach the target size. Even when downscaling, the clip is first enlarged 2× and then shrunk by the Downsizer; this is intended, the sharpening of the nnedi3 pass survives the downscale.
  • The final fmtconv step returns 16-bit for integer input.
  • If the current height is not mod 4, nnedi3 is skipped and only the Downsizer kernel resizes.
  • Network is always written; the other settings only when they differ from Hybrid's defaults.
  • YUV and RGB in integer or 32-bit float are accepted; on macOS the clip is converted to 32-bit float RGB.
  • With Stepped Resize this runs once per step.

Background

znedi3

znedi3 is a CPU-optimized port of nnedi3. Its documentation recommends neighbourhood 8x6 or 8x4 and Network 2 for enlarging. Prescreener 1 is the old one, 2–4 are levels of the new one; the new prescreener does not work on float clips, where the old one is used.

Sources