noise ¶
Classes:
-
GrainFactoryBicubic–Bicubic scaler originally implemented in GrainFactory with a sharp parameter.
-
Grainer–Enum representing different grain/noise generation algorithms.
-
ScalerTwoPasses–Scaler class that applies scaling in two passes.
Attributes:
-
LanczosTwoPasses–Lanczos resizer that applies scaling in two passes.
LanczosTwoPasses module-attribute ¶
LanczosTwoPasses = ScalerTwoPasses[Lanczos]
Lanczos resizer that applies scaling in two passes.
EdgeLimits ¶
Tuple representing lower and upper edge limits for each plane.
Format: (low, high)
Each element can be:
- A float: the same limit is applied to all planes.
- A sequence of floats: individual limits for each plane.
- True: use the default legal range per plane.
- False: no limits are applied.
GrainerLike ¶
GrainerLike = Grainer | GrainerPartial
Grainer-like type, which can be a single grainer or a partial grainer.
AbstractGrainer ¶
Abstract grainer base class.
Methods:
-
__call__–To be implemented in subclasses.
__call__ ¶
__call__(clip: VideoNode, /, **kwargs: Any) -> VideoNode | GrainerPartial
To be implemented in subclasses.
Source code in vsdeband/noise.py
131 132 133 | |
GrainFactoryBicubic ¶
Bases: BicubicAuto
Bicubic scaler originally implemented in GrainFactory with a sharp parameter.
Initialize the scaler with optional arguments.
Parameters:
-
(sharp¶float, default:50) –Sharpness of the scaler. Defaults to 50 which corresponds to Catrom scaling.
-
(**kwargs¶Any, default:{}) –Keyword arguments that configure the internal scaling behavior.
Source code in vsdeband/noise.py
115 116 117 118 119 120 121 122 123 | |
Grainer ¶
Bases: AbstractGrainer, CustomEnum
Enum representing different grain/noise generation algorithms.
Methods:
-
__call__–Apply grain to a clip using the selected graining method.
-
norm_brightness–Normalize the brightness of the grained clip to match the original clip's average luminance.
Attributes:
-
FBM_SIMPLEX–Fractional Brownian Motion based on Simplex noise.
-
GAUSS–Gaussian noise. Built-in vs-noise plugin.
-
PERLIN–Perlin noise. Built-in vs-noise plugin.
-
PLACEBO–Grain effect provided by the
libplaceborendering library. -
POISSON–Poisson-distributed noise. Built-in vs-noise plugin.
-
SIMPLEX–Simplex noise. Built-in vs-noise plugin.
FBM_SIMPLEX class-attribute instance-attribute ¶
FBM_SIMPLEX = 3
Fractional Brownian Motion based on Simplex noise. Built-in vs-noise plugin.
PLACEBO class-attribute instance-attribute ¶
PLACEBO = auto()
Grain effect provided by the libplacebo rendering library.
POISSON class-attribute instance-attribute ¶
POISSON = 4
Poisson-distributed noise. Built-in vs-noise plugin.
__call__ ¶
__call__(
clip: VideoNode,
/,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any,
) -> VideoNode
__call__(
*,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any
) -> GrainerPartial
__call__(
clip: VideoNode,
/,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
*,
size: int | tuple[float | None, float | None] | None = (2.0, 2.0),
**kwargs: Any,
) -> VideoNode
__call__(
*,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
size: int | tuple[float | None, float | None] | None = (2.0, 2.0),
**kwargs: Any
) -> GrainerPartial
__call__(
clip: VideoNode,
/,
strength: float | Sequence[float] = ...,
*,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any,
) -> VideoNode
__call__(
*,
strength: float | Sequence[float] = ...,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any
) -> GrainerPartial
__call__(
clip: VideoNode,
/,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any,
) -> VideoNode
__call__(
*,
strength: float | tuple[float, float] = ...,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any
) -> GrainerPartial
__call__(
clip: VideoNode | MissingT = MISSING,
/,
strength: float | Sequence[float] = 0,
static: bool = False,
scale: float | tuple[float, float] = 1.0,
scaler: ScalerLike = LanczosTwoPasses,
temporal: float | tuple[float, int] = (0.0, 0),
post_process: (
Callable[[VideoNode], VideoNode]
| Iterable[Callable[[VideoNode], VideoNode]]
| None
) = None,
protect_edges: bool | EdgeLimits = True,
protect_neutral_chroma: bool | None = None,
luma_scaling: float | None = None,
planes: Planes = None,
**kwargs: Any,
) -> VideoNode | GrainerPartial
Apply grain to a clip using the selected graining method.
If no clip is passed, a partially applied grainer with the provided arguments is returned instead.
Example usage
# For PERLIN, SIMPLEX, and FBM_SIMPLEX, it is recommended to use `size` instead of `scale`,
# as `size` allows for direct internal customization of each grain type.
grained = Grainer.PERLIN(clip, (1.65, 0.65), temporal=(0.25, 2), luma_scaling=4, size=3.0, seed=333)
Parameters:
-
(clip¶VideoNode | MissingT, default:MISSING) –The input clip to apply grain to. If omitted, returns a partially applied grainer.
-
(strength¶float | Sequence[float], default:0) –Grain strength. A single float applies uniform strength to all planes. A sequence allows per-plane control.
-
(static¶bool, default:False) –If True, the grain pattern is static (unchanging across frames).
-
(scale¶float | tuple[float, float], default:1.0) –Scaling divisor for the grain layer. Can be a float (uniform scaling) or a tuple (width, height scaling).
-
(scaler¶ScalerLike, default:LanczosTwoPasses) –Scaler used to resize the grain layer when
scaleis not 1.0. -
(temporal¶float | tuple[float, int], default:(0.0, 0)) –Temporal grain smoothing parameters. Either a float (weight) or a tuple of (weight, radius).
-
(post_process¶Callable[[VideoNode], VideoNode] | Iterable[Callable[[VideoNode], VideoNode]] | None, default:None) –One or more functions applied after grain generation (and temporal smoothing, if used).
-
(protect_edges¶bool | EdgeLimits, default:True) –Protects edge regions of each plane from graining.
- True: Use legal range based on clip format.
- False: Disable edge protection.
- Tuple: Specify custom edge limits per plane (see EdgeLimits).
-
(protect_neutral_chroma¶bool | None, default:None) –Whether to disable graining on neutral chroma.
-
(luma_scaling¶float | None, default:None) –Sensitivity of the luma-adaptive graining mask. Higher values reduce grain in brighter areas; negative values invert behavior.
-
(planes¶Planes, default:None) –Which planes to process. Default to all.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the graining function or additional advanced options:
temporal_avg_func: Temporal average function to use instead of the default standard mean.protect_edges_blend: Blend range (float) to soften edge protection thresholds.protect_neutral_chroma_blend: Blend range (float) for neutral chroma protection.neutral_out: (Boolean) Output the neutral layer instead of the merged clip.
Returns:
-
VideoNode | GrainerPartial–Grained video clip, or a GrainerPartial if
clipis not provided.
Source code in vsdeband/noise.py
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 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 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
norm_brightness staticmethod ¶
norm_brightness() -> Callable[[VideoNode], VideoNode]
Normalize the brightness of the grained clip to match the original clip's average luminance.
Designed for use in the post_process parameter of Grainer().
Returns:
-
Callable[[VideoNode], VideoNode]–A function that takes a grained clip and returns a brightness-normalized version.
Source code in vsdeband/noise.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
GrainerPartial ¶
Bases: AbstractGrainer
A partially-applied grainer wrapper.
Stores a grainer function, allowing it to be reused with different clips.
Parameters:
-
(grainer¶Grainer) –Grainer enumeration.
-
(**kwargs¶Any, default:{}) –Arguments for the specified grainer.
Methods:
-
__call__–Apply the grainer to the given clip with optional argument overrides.
Source code in vsdeband/noise.py
631 632 633 634 635 636 637 638 639 640 | |
__call__ ¶
Apply the grainer to the given clip with optional argument overrides.
Parameters:
-
(clip¶VideoNode) –Clip to be processed.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to override or extend the stored ones.
Returns:
-
VideoNode–Processed clip.
Source code in vsdeband/noise.py
642 643 644 645 646 647 648 649 650 651 652 653 | |
ScalerTwoPasses ¶
Bases: ScalerSpecializer[_ScalerWithLanczosDefaultT]
Scaler class that applies scaling in two passes.
Methods:
-
scale–
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Source code in vsdeband/noise.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |