Vapoursynth SSIMD

From wiki.selur.net
Revision as of 09:52, 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

SSIMD is an SSIM-based perceptual downscaler: the picture is first shrunk with a normal kernel and then corrected so that its local structure matches the large original. Perceptually important detail is kept, and the result stays temporally consistent. Hybrid uses it only for downscaling.

Filtering → Vapoursynth → Frame → Resize

SSIMD controls in Hybrid
SSIMD controls in Hybrid

What it does

After the pre-downscale, local means and variances of the source and of the small picture are compared on smoothed versions, and the small picture is adjusted so that its local contrast follows the original. Smooth type and its strength set the size of these local windows. Optionally luma is linearized with a gamma curve first, so the processing happens in linear light.

Settings

Tick Resizer in the Resizer page and pick SSIMD as method.

Control Parameter Range / values Hybrid default Meaning
Smooth type – box, tcanny box How the local windows are smoothed; picks which strength field is shown.
Box radius smooth 0 – 100 1 Box blur of (2 × radius + 1)² pixels: 1 = 3×3, 0 = no smoothing.
Sigma smooth 0 – 100 0.5 Gaussian sigma (with tcanny).
Kernel kernel Point, Rect, Linear, Bicubic, Lanczos, Blackman, BlackmanMinLobe, Spline16, Spline36, Spline64, Gauss, Sinc Bicubic fmtconv kernel of the pre-downscale.
Gamma correction gamma on/off off Linearizes luma (16 bit) before processing and re-applies the gamma afterwards.
Gamma curve curve 709, 601, 170, 240, 2020, srgb 709 Transfer curve used for the linearization; only with Gamma correction.
Sigmoid sigmoid on/off off Sigmoidal light curve that reduces dark halos from linear-light resizing; only with Gamma correction.
Tools: Expr, BoxBlur, TCanny – Expr: akarin, cranexpr, std; BoxBlur: vszip, std; TCanny: tcanny, std – Implementations; BoxBlur or TCanny is shown according to the smooth type (TCanny with std uses three box blurs).

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356), downscaled to 320x178:

# Resizing with SSIMD: 640x356 -> 320x178
clip = nnedi3_resample.SSIM_downsample(clip, w=320, h=178, smooth=1, use_fmtc=True, fulls=False, fulld=False, tools={'expr': 'akarin', 'boxblur': 'vszip', 'tcanny': 'tcanny'}) # 320x178 - YUV420PS

How Hybrid calls it

  • SSIMD scales to the target size of the Crop/Resize tab; the pre-downscale always uses fmtconv. Separately filtered fields are handled at field height.
  • If the target is larger than the current size in either dimension, SSIMD is skipped and fmtconv resizes with Spline64.
  • The output is 32-bit float (RGB, YUV 4:2:0 or YUV 4:4:4); Hybrid tracks this. The source range is passed as input and output range.
  • Kernel is written when it is not Bicubic.

Background

SSIM-based downscaling

The method is a modified implementation of the SSIM-based perceptual downscaling by Öztireli and Gross (2015). Apart from the gamma step all calculations run in 32-bit float. An integer smooth value means a box radius, a decimal value a Gaussian sigma.

Sources