enum ¶
Classes:
-
BlurMatrix
–Enum for predefined 1D and 2D blur kernel generators.
-
BlurMatrixBase
–Represents a convolution kernel (matrix) for spatial or temporal filtering.
-
LimitFilterMode
–Two sources, one filtered
BlurMatrix ¶
Bases: CustomEnum
Enum for predefined 1D and 2D blur kernel generators.
Provides commonly used blur kernels (e.g., mean, binomial, Gaussian) for convolution-based filtering.
Each kernel is returned as a BlurMatrixBase
object.
Methods:
-
__call__
–Generate the blur kernel based on the enum variant.
-
from_radius
–Generate a Gaussian blur kernel from an intuitive radius.
-
get_taps
–Compute the number of taps required for a given sigma value.
Attributes:
-
BINOMIAL
–Pascal triangle coefficients approximating Gaussian blur.
-
BOX_BLUR
– -
BOX_BLUR_NO_CENTER
– -
GAUSS
–Proper Gaussian kernel defined by
sigma
. -
MEAN
–Standard mean/box blur kernel including the center pixel. Aliased as BOX_BLUR.
-
MEAN_NO_CENTER
–Mean kernel excluding the center pixel. Also aliased as BOX_BLUR_NO_CENTER.
BINOMIAL class-attribute
instance-attribute
¶
BINOMIAL = auto()
Pascal triangle coefficients approximating Gaussian blur.
MEAN class-attribute
instance-attribute
¶
MEAN = auto()
Standard mean/box blur kernel including the center pixel. Aliased as BOX_BLUR.
MEAN_NO_CENTER class-attribute
instance-attribute
¶
MEAN_NO_CENTER = auto()
Mean kernel excluding the center pixel. Also aliased as BOX_BLUR_NO_CENTER.
__call__ ¶
Generate the blur kernel based on the enum variant.
Parameters:
-
taps
¶int | None
, default:None
) –Size of the kernel in each direction.
-
sigma
¶[GAUSS only] Standard deviation of the Gaussian kernel.
-
mode
¶Convolution mode. Default depends on kernel.
Returns:
-
Any
–A
BlurMatrixBase
instance representing the kernel.
Source code
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
from_radius ¶
from_radius(radius: int) -> BlurMatrixBase[float]
Generate a Gaussian blur kernel from an intuitive radius.
This is a shortcut that converts a blur radius to a corresponding sigma value.
Parameters:
Returns:
-
BlurMatrixBase[float]
–Gaussian blur matrix.
Source code
354 355 356 357 358 359 360 361 362 363 364 365 |
|
get_taps ¶
Compute the number of taps required for a given sigma value.
Parameters:
-
sigma
¶float
) –Gaussian sigma value.
-
taps
¶int | None
, default:None
) –Optional manual override; if not provided, it's computed from sigma.
Returns:
-
int
–Number of taps.
Source code
367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
BlurMatrixBase ¶
BlurMatrixBase(__iterable: Iterable[_Nb], /, mode: ConvMode = SQUARE)
Bases: list[_Nb]
Represents a convolution kernel (matrix) for spatial or temporal filtering.
This class is typically constructed via the BlurMatrix
enum, and encapsulates both the filter values and the intended convolution mode (e.g., horizontal, vertical, square, temporal).
When called, it applies the convolution to a clip using the appropriate method (std.Convolution
, std.AverageFrames
, or a custom ExprOp
expression), depending on the kernel's properties and context.
Example:
kernel = BlurMatrix.BINOMIAL(taps=2)
blurred = kernel(clip)
Parameters:
-
__iterable
¶Iterable[_Nb]
) –Iterable of kernel coefficients.
-
mode
¶ConvMode
, default:SQUARE
) –Convolution mode to use. Default is SQUARE.
Methods:
-
__call__
–Apply the blur kernel to the given clip via spatial or temporal convolution.
-
outer
–Convert a 1D kernel into a 2D square kernel by computing the outer product.
Attributes:
-
mode
–
Source code
68 69 70 71 72 73 74 75 76 |
|
__call__ ¶
__call__(
clip: VideoNode,
planes: PlanesT = None,
bias: float | None = None,
divisor: float | None = None,
saturate: bool = True,
passes: int = 1,
expr_kwargs: KwargsT | None = None,
**conv_kwargs: Any
) -> ConstantFormatVideoNode
Apply the blur kernel to the given clip via spatial or temporal convolution.
Chooses the appropriate backend (std.Convolution
, std.AverageFrames
, or ExprOp.convolution
) depending on kernel size, mode, format, and other constraints.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
planes
¶PlanesT
, default:None
) –Planes to process. Defaults to all.
-
bias
¶float | None
, default:None
) –Value added to result before clamping.
-
divisor
¶float | None
, default:None
) –Divides the result of the convolution (before adding bias). Defaults to sum of kernel values.
-
saturate
¶bool
, default:True
) –If True, negative values are clamped to zero. If False, absolute values are returned.
-
passes
¶int
, default:1
) –Number of convolution passes to apply.
-
expr_kwargs
¶KwargsT | None
, default:None
) –Extra kwargs passed to ExprOp.convolution when used.
-
**conv_kwargs
¶Any
, default:{}
) –Any other args passed to the underlying VapourSynth function.
Returns:
-
ConstantFormatVideoNode
–Processed (blurred) video clip.
Source code
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
outer ¶
outer() -> Self
Convert a 1D kernel into a 2D square kernel by computing the outer product.
Returns:
-
Self
–New
BlurMatrixBase
instance with 2D kernel and same mode.
Source code
212 213 214 215 216 217 218 219 220 |
|
LimitFilterMode ¶
Bases: LimitFilterModeMeta
, CustomIntEnum
Two sources, one filtered
Methods:
-
__call__
–
Attributes:
-
CLAMPING
– -
DIFF_MAX
–One/Two sources, one filtered
-
DIFF_MIN
– -
SIMPLE2_MAX
– -
SIMPLE2_MIN
– -
SIMPLE_MAX
–One source, two filtered
-
SIMPLE_MIN
– -
force_expr
– -
op
(str
) –