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.
-
custom
–Create a custom BlurMatrixBase kernel with explicit values and mode.
-
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
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
|
custom classmethod
¶
Create a custom BlurMatrixBase kernel with explicit values and mode.
Parameters:
-
values
¶Iterable[_Nb]
) –The kernel coefficients.
-
mode
¶ConvMode
, default:SQUARE
) –Convolution mode to use.
Returns:
-
BlurMatrixBase[_Nb]
–A BlurMatrixBase instance.
Source code
457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
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
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
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
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
BlurMatrixBase ¶
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
82 83 84 85 86 87 88 89 |
|
__call__ ¶
__call__(
clip: VideoNode | Iterable[VideoNode],
planes: PlanesT = None,
bias: float | None = None,
divisor: float | None = None,
saturate: bool = True,
passes: int = 1,
func: FuncExceptT | None = None,
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 | Iterable[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.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
-
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
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
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
270 271 272 273 274 275 276 277 278 279 |
|
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
) –