Skip to content

noise

Classes:

  • AddNoise
  • GrainFactoryBicubic

    Bicubic scaler originally implemented in GrainFactory with a sharp parameter.

  • Grainer

    Enum representing different grain/noise generation algorithms.

  • ScalerTwoPasses

    Abstract scaler class that applies scaling in two passes.

Attributes:

EdgeLimits module-attribute

EdgeLimits = tuple[
    float | Sequence[float] | bool, float | Sequence[float] | bool
]

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 module-attribute

GrainerLike: TypeAlias = Grainer | GrainerPartial

Grainer-like type, which can be a single grainer or a partial grainer.

LanczosTwoPasses module-attribute

LanczosTwoPasses = ScalerTwoPasses[Lanczos]

Lanczos resizer that applies scaling in two passes.

AbstractGrainer

Abstract grainer base class.

Methods:

__call__

__call__(clip: VideoNode, /, **kwargs: Any) -> VideoNode | GrainerPartial
Source code
138
139
def __call__(self, clip: vs.VideoNode, /, **kwargs: Any) -> vs.VideoNode | GrainerPartial:
    raise NotImplementedError

AddNoise

AddNoise(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Classes:

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

FBM_SIMPLEX

FBM_SIMPLEX(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

GAUSS

GAUSS(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

PERLIN

PERLIN(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

POISSON

POISSON(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

SIMPLEX

SIMPLEX(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Bases: AddNoiseBase

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

AddNoiseBase

AddNoiseBase(
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any
)

Methods:

Attributes:

Source code
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
def __init__(
    self,
    strength: float | tuple[float, float] = 0.25,
    size: float | tuple[float, float] = (1.0, 1.0),
    sharp: float | ScalerLike = Lanczos,
    dynamic: bool = True,
    temporal_average: int | tuple[float, int] = (0.0, 1),
    postprocess: Any | None = None,
    protect_chroma: bool = True,
    luma_scaling: float | None = None,
    fade_limits: bool | Any = True,
    *,
    matrix: Any | None = None,
    kernel: Any = None,
    neutral_out: bool = False,
    **kwargs: Any,
) -> None:
    self.strength = strength
    self.size = size
    self.sharp = sharp
    self.dynamic = dynamic
    self.temporal_average = temporal_average
    self.postprocess = postprocess
    self.protect_chroma = protect_chroma
    self.luma_scaling = luma_scaling
    self.fade_limits = fade_limits
    self.neutral_out = neutral_out
    self.kwargs = kwargs

dynamic instance-attribute

dynamic = dynamic

fade_limits instance-attribute

fade_limits = fade_limits

kwargs instance-attribute

kwargs = kwargs

luma_scaling instance-attribute

luma_scaling = luma_scaling

neutral_out instance-attribute

neutral_out = neutral_out

postprocess instance-attribute

postprocess = postprocess

protect_chroma instance-attribute

protect_chroma = protect_chroma

sharp instance-attribute

sharp = sharp

size instance-attribute

size = size

strength instance-attribute

strength = strength

temporal_average instance-attribute

temporal_average = temporal_average

grain

grain(
    clip: VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any
) -> VideoNode
Source code
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
@inject_self
def grain(
    self,
    clip: vs.VideoNode,
    strength: float | tuple[float, float] | None = None,
    dynamic: bool | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    scaler = (
        GrainFactoryBicubic(self.sharp + 50)
        if isinstance(self.sharp, (float, int))
        else ScalerTwoPasses[Scaler.from_param(self.sharp)]  # type: ignore[misc]
    )
    return Grainer(self._noise_type)(  # type: ignore[misc]
        clip,
        fallback(strength, self.strength),
        not fallback(dynamic, self.dynamic),
        self.size,
        scaler,  # type: ignore[arg-type]
        self.temporal_average,
        self.postprocess,
        self.fade_limits,
        self.protect_chroma,
        self.luma_scaling,
        neutral_out=self.neutral_out,
        **self.kwargs | kwargs,
    )

GrainFactoryBicubic

GrainFactoryBicubic(sharp: float = 50, **kwargs: Any)

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
122
123
124
125
126
127
128
129
130
def __init__(self, sharp: float = 50, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional arguments.

    Args:
        sharp: Sharpness of the scaler. Defaults to 50 which corresponds to Catrom scaling.
        **kwargs: Keyword arguments that configure the internal scaling behavior.
    """
    super().__init__(sharp / -50 + 1, None, **kwargs)

Grainer

Bases: AbstractGrainer, CustomEnum

Enum representing different grain/noise generation algorithms.

Methods:

  • __call__

    Apply grain to a clip using the selected graining method.

Attributes:

FBM_SIMPLEX class-attribute instance-attribute

FBM_SIMPLEX = 3

Fractional Brownian Motion based on Simplex noise. Built-in vs-noise plugin.

GAUSS class-attribute instance-attribute

GAUSS = 0

Gaussian noise. Built-in vs-noise plugin.

PERLIN class-attribute instance-attribute

PERLIN = 1

Perlin 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.

SIMPLEX class-attribute instance-attribute

SIMPLEX = 2

Simplex 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = 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 scale is 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

    (_PostProcessFunc | Iterable[_PostProcessFunc] | 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.

  • **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 clip is not provided.

Source code
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
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
def __call__(
    self,
    clip: vs.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: _PostProcessFunc | Iterable[_PostProcessFunc] | None = None,
    protect_edges: bool | EdgeLimits = True,
    protect_neutral_chroma: bool | None = None,
    luma_scaling: float | None = None,
    **kwargs: Any,
) -> vs.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:
        ```py
        # 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)
        ```

    Args:
        clip:
            The input clip to apply grain to. If omitted, returns a partially applied grainer.
        strength:
            Grain strength.
            A single float applies uniform strength to all planes.
            A sequence allows per-plane control.

        static:
            If True, the grain pattern is static (unchanging across frames).
        scale:
            Scaling divisor for the grain layer.
            Can be a float (uniform scaling) or a tuple (width, height scaling).
        scaler:
            Scaler used to resize the grain layer when `scale` is not 1.0.
        temporal:
            Temporal grain smoothing parameters. Either a float (weight) or a tuple of (weight, radius).
        post_process:
            One or more functions applied after grain generation (and temporal smoothing, if used).
        protect_edges:
            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:
            Whether to disable graining on neutral chroma.
        luma_scaling:
            Sensitivity of the luma-adaptive graining mask.
            Higher values reduce grain in brighter areas; negative values invert behavior.
        **kwargs:
            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:
        Grained video clip, or a `GrainerPartial` if `clip` is not provided.
    """
    kwargs.update(
        strength=strength,
        scale=scale,
        scaler=scaler,
        temporal=temporal,
        protect_edges=protect_edges,
        post_process=post_process,
        protect_neutral_chroma=protect_neutral_chroma,
        luma_scaling=luma_scaling,
    )

    if clip is MISSING:
        return GrainerPartial(self, **kwargs)

    assert check_variable(clip, self.name)

    if self == Grainer.PLACEBO:
        assert static is False, "PlaceboGrain does not support static noise!"

        grained = _apply_grainer(
            clip,
            lambda clip, strength, planes, **kwds: placebo_deband(
                clip, 8, 0.0, strength, planes, iterations=1, **kwds
            ),
            **kwargs,
            func=self.name,
        )
    else:
        if not isinstance(size := kwargs.pop("size", (None, None)), tuple):
            size = (size, size)

        kwargs.update(xsize=size[0], ysize=size[1])

        grained = _apply_grainer(
            clip,
            lambda clip, strength, planes, **kwds: core.noise.Add(
                clip,
                *strength[:2],  # type: ignore[misc]
                type=self.value,
                constant=static,
                **kwds,
            ),
            **kwargs,
            func=self.name,
        )

    return grained

GrainerPartial

GrainerPartial(grainer: Grainer, **kwargs: Any)

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.

Attributes:

Source code
580
581
582
583
584
585
586
587
588
589
def __init__(self, grainer: Grainer, **kwargs: Any) -> None:
    """
    Stores a grainer function, allowing it to be reused with different clips.

    Args:
        grainer: [Grainer][vsdeband.noise.Grainer] enumeration.
        **kwargs: Arguments for the specified grainer.
    """
    self.grainer = grainer
    self.kwargs = kwargs

grainer instance-attribute

grainer = grainer

kwargs instance-attribute

kwargs = kwargs

__call__

__call__(clip: VideoNode, /, **kwargs: Any) -> VideoNode

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
591
592
593
594
595
596
597
598
599
600
601
602
def __call__(self, clip: vs.VideoNode, /, **kwargs: Any) -> vs.VideoNode:
    """
    Apply the grainer to the given clip with optional argument overrides.

    Args:
        clip: Clip to be processed.
        **kwargs: Additional keyword arguments to override or extend the stored ones.

    Returns:
        Processed clip.
    """
    return self.grainer(clip, **self.kwargs | kwargs)

ScalerTwoPasses

Bases: BaseScalerSpecializer[_ScalerT], Scaler

Abstract scaler class that applies scaling in two passes.

Methods:

scale

scale(
    clip: VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any
) -> VideoNode | ConstantFormatVideoNode
Source code
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
def scale(
    self,
    clip: vs.VideoNode,
    width: int | None = None,
    height: int | None = None,
    shift: tuple[TopShift, LeftShift] = (0, 0),
    **kwargs: Any,
) -> vs.VideoNode | ConstantFormatVideoNode:
    assert check_variable(clip, self.__class__)

    width, height = self._wh_norm(clip, width, height)

    if width / clip.width > 1.5 or height / clip.height > 1.5:
        # If the scale is too big, we need to scale it in two passes, else the window
        # will be too big and the grain will be dampened down too much
        mod = max(clip.format.subsampling_w, clip.format.subsampling_h) << 1
        clip = super().scale(
            clip, mod_x((width + clip.width) / 2, mod), mod_x((height + clip.height) / 2, mod), **kwargs
        )

    return super().scale(clip, width, height, (0, 0), **kwargs)