Vapoursynth Balance Borders

From wiki.selur.net
Revision as of 09:47, 16 November 2026 by Selur (talk | contribs) (New filter page (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

BalanceBorders (checkbox Balanced Borders) fixes discolored or too dark/bright rows and columns along the frame edges ("dirty lines").

Filtering → Vapoursynth → Frame → Edge

BalanceBorders controls in Hybrid
BalanceBorders controls in Hybrid

What it does

For each edge the given number of lines is compared with the first clean line next to them. Both are blurred horizontally, and the border lines are pulled towards the clean line: luma by a ratio, chroma by its distance from neutral. Threshold caps how far a luma pixel may move. An edge with 0 lines is left alone.

Settings

Control Parameter Range / values Hybrid default Meaning
Border (l/t/r/b) cLeft / cTop / cRight / cBottom 0 – 512 each 0 Lines to fix on the left, top, right and bottom edge.
Threshold thresh 1 – 128 128 Largest luma change per pixel (8-bit scale); 128 = no cap.
Blur blur 1 – 16384 999 Blur width = max(8, frame width / Blur); a smaller value gives a wider blur.
Tools: Expr – akarin, cranexpr, std – Expr implementation.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# Fix bright and dark line artifacts near the border of an image using BalanceBorders
clip = edge.bbmod(clip, cLeft=0, cTop=0, cRight=0, cBottom=0, tools={'expr': 'akarin'})

How Hybrid calls it

  • BalanceBorders works on 8–16-bit integer YUV; gray and RGB are not accepted, other formats are converted first.
  • The four border values are always written, Threshold and Blur only when they differ from the defaults.
  • Threshold stays on the 8-bit scale; it is scaled to the bit depth of the clip.
  • The frame is upscaled 2× internally, so odd border sizes also work with subsampled chroma. The cap applies to luma only.
  • Frame count and frame rate do not change.

Background

Origin

The function is BalanceBordersMod (bbmod), taken from the old havsfunc; it goes back to the AviSynth script BalanceBorders. The same function is also part of awsmfunc. For a regression-based alternative see Bore and EdgeFixer.

Sources