Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

deflate

deflate(
  input: Clip,
  #{
    planes?: Array<Int>,
    threshold?: Int | Float,
  }
)

Replaces each processed pixel with the average of the eight pixels in its 3x3 neighborhood when that average is less than the center pixel.

The input must be one fixed-format planar Gray, YUV, or planar RGB clip. Edge pixels use mirrored neighbor coordinates so the filter can evaluate a full eight-sample neighborhood at the image borders. Integer formats round the eight-neighbor average to the nearest integer before comparing it against the center pixel. Float formats use the exact sum / 8.0 average.

If threshold is omitted or set to (), the output sample changes all the way to the computed neighborhood average. If threshold is set, the absolute difference between the input sample and output sample is capped to that value. Integer thresholds must be non-negative and stay within the format’s code range. Float thresholds must be finite and within 0.0..=1.0.

If planes is omitted, every plane is processed. If planes is provided, only the listed zero-based plane indexes are processed; all other planes are preserved without modification. An empty array processes no planes.

Examples

output = source("input.mkv").std.deflate()
output = source("input.mkv").std.deflate(#{ threshold: 4, planes: [0] })

Input

One fixed-format planar Gray, YUV, or planar RGB clip.

Output

A clip with the same format, resolution, timing, and metadata, with selected planes reduced toward their mirrored-edge neighborhood averages.

Options

  • planes (Array<Int>, default: all planes) – Zero-based plane indexes to process. Unlisted planes are preserved without modification. An empty array processes no planes.
  • threshold (Int | Float, default: none) – Maximum allowed absolute change from the input sample to the output sample. Use Int for integer formats and Float in 0.0..=1.0 for float formats.