enum ¶
Classes:
-
BlurMatrix
–Enum for predefined 1D and 2D blur kernel generators.
-
BlurMatrixBase
–Represents a convolution kernel (matrix) for spatial or temporal filtering.
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 in vsrgtools/enum.py
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 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 |
|
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 in vsrgtools/enum.py
417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
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 in vsrgtools/enum.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
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 in vsrgtools/enum.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
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 in vsrgtools/enum.py
48 49 50 51 52 53 54 55 |
|
__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 in vsrgtools/enum.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
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 in vsrgtools/enum.py
230 231 232 233 234 235 236 237 238 239 |
|