Skip to content

rgtools

Functions:

  • clense

    Apply a clense (temporal median) filter based on the specified mode.

  • remove_grain

    Apply spatial denoising using the RemoveGrain algorithm.

  • repair

    Constrains the input clip using a repairclip by clamping pixel values

  • vertical_cleaner

    Applies a fast vertical median or relaxed median filter to the clip

Attributes:

removegrain module-attribute

removegrain = remove_grain

Clense

Clense(clense_func: Callable[P, R])

Bases: Generic[P, R]

Class decorator that wraps the clense function and extends its functionality.

It is not meant to be used directly.

Classes:

  • Mode

    Enum that specifies the temporal clense mode to use.

Methods:

Source code
492
493
def __init__(self, clense_func: Callable[P, R]) -> None:
    self._func = clense_func

Mode

Bases: CustomStrEnum

Enum that specifies the temporal clense mode to use.

Clense modes refer to different ways of applying temporal median filtering over multiple frames.

Each mode maps to a function provided by the zsmooth plugin.

Methods:

  • __call__

    Apply the selected clense mode to a clip using

Attributes:

  • BACKWARD

    Use the current and previous two frames for temporal median filtering.

  • BOTH

    Standard clense: median of previous, current, and next frame.

  • FORWARD

    Use the current and next two frames for temporal median filtering.

  • NONE

    No clense filtering. Returns the original clip unchanged.

BACKWARD class-attribute instance-attribute

BACKWARD = 'BackwardClense'

Use the current and previous two frames for temporal median filtering.

BOTH class-attribute instance-attribute

BOTH = 'Clense'

Standard clense: median of previous, current, and next frame.

FORWARD class-attribute instance-attribute

FORWARD = 'ForwardClense'

Use the current and next two frames for temporal median filtering.

NONE class-attribute instance-attribute

NONE = ''

No clense filtering. Returns the original clip unchanged.

__call__

__call__(
    clip: VideoNode,
    previous_clip: VideoNode | None = None,
    next_clip: VideoNode | None = None,
    planes: PlanesT = None,
) -> ConstantFormatVideoNode

Apply the selected clense mode to a clip using the zsmooth plugin.

Parameters:

  • clip
    (VideoNode) –

    Source clip to process.

  • previous_clip
    (VideoNode | None, default: None ) –

    Optional alternate clip to source previous frames. Defaults to clip.

  • next_clip
    (VideoNode | None, default: None ) –

    Optional alternate clip to source next frames. Defaults to clip.

  • planes
    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Clensed clip with temporal median filtering.

Source code
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
def __call__(
    self,
    clip: vs.VideoNode,
    previous_clip: vs.VideoNode | None = None,
    next_clip: vs.VideoNode | None = None,
    planes: PlanesT = None,
) -> ConstantFormatVideoNode:
    """
    Apply the selected clense mode to a clip using
    the [zsmooth](https://github.com/adworacz/zsmooth?tab=readme-ov-file#clense--forwardclense--backwardclense)
    plugin.

    Args:
        clip: Source clip to process.
        previous_clip: Optional alternate clip to source previous frames. Defaults to `clip`.
        next_clip: Optional alternate clip to source next frames. Defaults to `clip`.
        planes: Planes to process. Defaults to all.

    Returns:
        Clensed clip with temporal median filtering.
    """
    return clense(clip, previous_clip, next_clip, self, planes)

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
495
496
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
    return self._func(*args, **kwargs)

RemoveGrain

RemoveGrain(repair_func: Callable[P, R])

Bases: Generic[P, R]

Class decorator that wraps the remove_grain function and extends its functionality.

It is not meant to be used directly.

Classes:

  • Mode

    Enum representing available spatial filtering strategies in RemoveGrain.

Methods:

Source code
259
260
def __init__(self, repair_func: Callable[P, R]) -> None:
    self._func = repair_func

Mode

Bases: CustomIntEnum

Enum representing available spatial filtering strategies in RemoveGrain.

These modes serve a wide range of use cases, such as clamping outliers, removing noise, or simple dehaloing.

More information here.

Methods:

  • __call__

    Apply the selected remove grain mode to a clip.

Attributes:

  • BINOMIAL_BLUR

    Deprecated. Use BlurMatrix.BINOMIAL. Applies weighted 3x3 blur.

  • BOB_BOTTOM_CLOSE

    Interpolate bottom field using the closest neighboring pixels.

  • BOB_BOTTOM_INTER

    Bottom field interpolation using a more complex formula than mode 14.

  • BOB_TOP_CLOSE

    Interpolate top field using the closest neighboring pixels.

  • BOB_TOP_INTER

    Top field interpolation using a more complex formula than mode 13.

  • BOX_BLUR

    Alias for MEAN.

  • BOX_BLUR_NO_CENTER

    Alias for MEAN_NO_CENTER.

  • EDGE_CLIP_LIGHT

    Light edge clipping (prioritizes the range between opposites).

  • EDGE_CLIP_MEDIUM

    Balanced version of mode 6 (change vs. range ratio 1:1).

  • EDGE_CLIP_MODERATE

    Line-sensitive clipping with moderate sensitivity (change prioritized 2:1).

  • EDGE_CLIP_STRONG

    Line-sensitive clipping that minimizes change to the center pixel.

  • EDGE_DEHALO

    Very light dehaloing. Rarely useful.

  • EDGE_DEHALO2

    More conservative version of mode 23.

  • LINE_CLIP_CLOSE

    Clip using the line with closest neighbors. Useful for fixing 1-pixel gaps.

  • LINE_CLIP_OPP

    Line-sensitive clipping using opposite neighbors with minimal deviation.

  • MEAN

    Deprecated. Use BlurMatrix.MEAN. Arithmetic mean of 3x3 neighborhood.

  • MEAN_NO_CENTER

    Deprecated. Use BlurMatrix.MEAN_NO_CENTER. Mean of neighborhood (excluding center).

  • MINMAX_AROUND1

    Clamp pixel to the min/max of its 3x3 neighborhood (excluding center).

  • MINMAX_AROUND2

    Clamp to the second lowest/highest in the neighborhood.

  • MINMAX_AROUND3

    Clamp to the third lowest/highest in the neighborhood.

  • MINMAX_MEDIAN

    Deprecated. Similar to mode 1, but clamps to fourth-lowest/highest.

  • MINMAX_MEDIAN_OPP

    Clip using min/max of opposing neighbor pairs.

  • MIN_SHARP

    Replaces pixel with its closest neighbor. A poor but sharp denoiser.

  • MIN_SHARP2

    Minimal sharpening also known as "non destructive sharpen".

  • NONE

    The input plane is simply passed through.

  • OPP_CLIP_AVG

    Clip to min/max of averages of 4 opposing pixel pairs.

  • OPP_CLIP_AVG_FAST

    Faster variant of mode 21 with simpler rounding.

  • SMART_RGC

    Like mode 17, but preserves corners. Does not preserve thin lines.

  • SMART_RGCL

    Uses 12 pixel pairs instead of 8. Similar to 26, but slightly stronger.

  • SMART_RGCL2

    Variant of 27 with different pairs. Usually visually similar.

BINOMIAL_BLUR class-attribute instance-attribute

BINOMIAL_BLUR = 11

Deprecated. Use BlurMatrix.BINOMIAL. Applies weighted 3x3 blur.

BOB_BOTTOM_CLOSE class-attribute instance-attribute

BOB_BOTTOM_CLOSE = 14

Interpolate bottom field using the closest neighboring pixels.

BOB_BOTTOM_INTER class-attribute instance-attribute

BOB_BOTTOM_INTER = 16

Bottom field interpolation using a more complex formula than mode 14.

BOB_TOP_CLOSE class-attribute instance-attribute

BOB_TOP_CLOSE = 13

Interpolate top field using the closest neighboring pixels.

BOB_TOP_INTER class-attribute instance-attribute

BOB_TOP_INTER = 15

Top field interpolation using a more complex formula than mode 13.

BOX_BLUR class-attribute instance-attribute

BOX_BLUR = MEAN

Alias for MEAN.

BOX_BLUR_NO_CENTER class-attribute instance-attribute

BOX_BLUR_NO_CENTER = MEAN_NO_CENTER

Alias for MEAN_NO_CENTER.

EDGE_CLIP_LIGHT class-attribute instance-attribute

EDGE_CLIP_LIGHT = 8

Light edge clipping (prioritizes the range between opposites).

EDGE_CLIP_MEDIUM class-attribute instance-attribute

EDGE_CLIP_MEDIUM = 7

Balanced version of mode 6 (change vs. range ratio 1:1).

EDGE_CLIP_MODERATE class-attribute instance-attribute

EDGE_CLIP_MODERATE = 6

Line-sensitive clipping with moderate sensitivity (change prioritized 2:1).

EDGE_CLIP_STRONG class-attribute instance-attribute

EDGE_CLIP_STRONG = 5

Line-sensitive clipping that minimizes change to the center pixel.

EDGE_DEHALO class-attribute instance-attribute

EDGE_DEHALO = 23

Very light dehaloing. Rarely useful.

EDGE_DEHALO2 class-attribute instance-attribute

EDGE_DEHALO2 = 24

More conservative version of mode 23.

LINE_CLIP_CLOSE class-attribute instance-attribute

LINE_CLIP_CLOSE = 9

Clip using the line with closest neighbors. Useful for fixing 1-pixel gaps.

LINE_CLIP_OPP class-attribute instance-attribute

LINE_CLIP_OPP = 18

Line-sensitive clipping using opposite neighbors with minimal deviation.

MEAN class-attribute instance-attribute

MEAN = 20

Deprecated. Use BlurMatrix.MEAN. Arithmetic mean of 3x3 neighborhood.

MEAN_NO_CENTER class-attribute instance-attribute

MEAN_NO_CENTER = 19

Deprecated. Use BlurMatrix.MEAN_NO_CENTER. Mean of neighborhood (excluding center).

MINMAX_AROUND1 class-attribute instance-attribute

MINMAX_AROUND1 = 1

Clamp pixel to the min/max of its 3x3 neighborhood (excluding center).

MINMAX_AROUND2 class-attribute instance-attribute

MINMAX_AROUND2 = 2

Clamp to the second lowest/highest in the neighborhood.

MINMAX_AROUND3 class-attribute instance-attribute

MINMAX_AROUND3 = 3

Clamp to the third lowest/highest in the neighborhood.

MINMAX_MEDIAN class-attribute instance-attribute

MINMAX_MEDIAN = 4

Deprecated. Similar to mode 1, but clamps to fourth-lowest/highest.

MINMAX_MEDIAN_OPP class-attribute instance-attribute

MINMAX_MEDIAN_OPP = 17

Clip using min/max of opposing neighbor pairs.

MIN_SHARP class-attribute instance-attribute

MIN_SHARP = 10

Replaces pixel with its closest neighbor. A poor but sharp denoiser.

MIN_SHARP2 class-attribute instance-attribute

MIN_SHARP2 = 25

Minimal sharpening also known as "non destructive sharpen".

NONE class-attribute instance-attribute

NONE = 0

The input plane is simply passed through.

OPP_CLIP_AVG class-attribute instance-attribute

OPP_CLIP_AVG = 21

Clip to min/max of averages of 4 opposing pixel pairs.

OPP_CLIP_AVG_FAST class-attribute instance-attribute

OPP_CLIP_AVG_FAST = 22

Faster variant of mode 21 with simpler rounding.

SMART_RGC class-attribute instance-attribute

SMART_RGC = 26

Like mode 17, but preserves corners. Does not preserve thin lines.

SMART_RGCL class-attribute instance-attribute

SMART_RGCL = 27

Uses 12 pixel pairs instead of 8. Similar to 26, but slightly stronger.

SMART_RGCL2 class-attribute instance-attribute

SMART_RGCL2 = 28

Variant of 27 with different pairs. Usually visually similar.

__call__

__call__(clip: VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode

Apply the selected remove grain mode to a clip.

Parameters:

  • clip
    (VideoNode) –

    Clip to process.

  • planes
    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Processed (denoised) clip.

Source code
425
426
427
428
429
430
431
432
433
434
435
436
def __call__(self, clip: vs.VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode:
    """
    Apply the selected remove grain mode to a `clip`.

    Args:
        clip: Clip to process.
        planes: Planes to process. Defaults to all.

    Returns:
        Processed (denoised) clip.
    """
    return remove_grain(clip, self, planes)

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
262
263
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
    return self._func(*args, **kwargs)

Repair

Repair(repair_func: Callable[P, R])

Bases: Generic[P, R]

Class decorator that wraps the repair function and extends its functionality.

It is not meant to be used directly.

Classes:

  • Mode

    Enum that specifies the mode for repairing or limiting a source clip using a reference clip.

Methods:

Source code
23
24
def __init__(self, repair_func: Callable[P, R]) -> None:
    self._func = repair_func

Mode

Bases: CustomIntEnum

Enum that specifies the mode for repairing or limiting a source clip using a reference clip.

These modes define different spatial strategies for constraining each pixel in the source clip based on the reference clip's local neighborhood, typically using 3x3 squares or line-sensitive patterns.

Commonly used in denoising, artifact removal, or detail-preserving restoration.

Methods:

  • __call__

    Apply the selected repair mode to a clip using a repairclip.

Attributes:

  • CLIP_REF_RG17

    Use RemoveGrain mode 17's result to constrain the pixel.

  • CLIP_REF_RG18

    Use RemoveGrain mode 18's result to constrain the pixel.

  • CLIP_REF_RG19

    Use RemoveGrain mode 19's result to constrain the pixel.

  • CLIP_REF_RG20

    Use RemoveGrain mode 20's result to constrain the pixel.

  • CLIP_REF_RG21

    Use RemoveGrain mode 21's result to constrain the pixel.

  • CLIP_REF_RG22

    Use RemoveGrain mode 22's result to constrain the pixel.

  • CLIP_REF_RG23

    Use RemoveGrain mode 23's result to constrain the pixel.

  • CLIP_REF_RG24

    Use RemoveGrain mode 24's result to constrain the pixel.

  • CLIP_REF_RG26

    Use RemoveGrain mode 26's result to constrain the pixel.

  • CLIP_REF_RG27

    Use RemoveGrain mode 27's result to constrain the pixel.

  • CLIP_REF_RG28

    Use RemoveGrain mode 28's result to constrain the pixel.

  • CLIP_REF_RG5

    Use RemoveGrain mode 5's result to constrain the pixel.

  • CLIP_REF_RG6

    Use RemoveGrain mode 6's result to constrain the pixel.

  • LINE_CLIP_CLOSE

    Line-sensitive clamp using the closest neighbors.

  • LINE_CLIP_LIGHT

    Line-sensitive clamping with a light effect.

  • LINE_CLIP_MEDIUM

    Line-sensitive clamping with a moderate effect.

  • LINE_CLIP_MIN

    Line-sensitive clamping with minimal alteration.

  • LINE_CLIP_STRONG

    Line-sensitive clamping with a strong effect.

  • MINMAX_SQUARE1

    Clamp using the 1st min/max from a 3x3 square in the reference clip.

  • MINMAX_SQUARE2

    Clamp using the 2nd min/max from a 3x3 square in the reference clip.

  • MINMAX_SQUARE3

    Clamp using the 3rd min/max from a 3x3 square in the reference clip.

  • MINMAX_SQUARE4

    Clamp using the 4th min/max from a 3x3 square in the reference clip.

  • MINMAX_SQUARE_REF1

    Same as mode 1, but clips with min/max of 1st rank and the center pixel of the reference clip.

  • MINMAX_SQUARE_REF2

    Same as mode 2, but clips with min/max of 2nd rank and the center pixel of the reference clip.

  • MINMAX_SQUARE_REF3

    Same as mode 3, but clips with min/max of 3rd rank and the center pixel of the reference clip.

  • MINMAX_SQUARE_REF4

    Same as mode 4, but clips with min/max of 4th rank and the center pixel of the reference clip.

  • MINMAX_SQUARE_REF_CLOSE

    Replace pixel with the closest value in the 3x3 reference square.

  • NONE

    No repair. The input plane is passed through unchanged.

CLIP_REF_RG17 class-attribute instance-attribute

CLIP_REF_RG17 = 17

Use RemoveGrain mode 17's result to constrain the pixel.

CLIP_REF_RG18 class-attribute instance-attribute

CLIP_REF_RG18 = 18

Use RemoveGrain mode 18's result to constrain the pixel.

CLIP_REF_RG19 class-attribute instance-attribute

CLIP_REF_RG19 = 19

Use RemoveGrain mode 19's result to constrain the pixel.

CLIP_REF_RG20 class-attribute instance-attribute

CLIP_REF_RG20 = 20

Use RemoveGrain mode 20's result to constrain the pixel.

CLIP_REF_RG21 class-attribute instance-attribute

CLIP_REF_RG21 = 21

Use RemoveGrain mode 21's result to constrain the pixel.

CLIP_REF_RG22 class-attribute instance-attribute

CLIP_REF_RG22 = 22

Use RemoveGrain mode 22's result to constrain the pixel.

CLIP_REF_RG23 class-attribute instance-attribute

CLIP_REF_RG23 = 23

Use RemoveGrain mode 23's result to constrain the pixel.

CLIP_REF_RG24 class-attribute instance-attribute

CLIP_REF_RG24 = 24

Use RemoveGrain mode 24's result to constrain the pixel.

CLIP_REF_RG26 class-attribute instance-attribute

CLIP_REF_RG26 = 26

Use RemoveGrain mode 26's result to constrain the pixel.

CLIP_REF_RG27 class-attribute instance-attribute

CLIP_REF_RG27 = 27

Use RemoveGrain mode 27's result to constrain the pixel.

CLIP_REF_RG28 class-attribute instance-attribute

CLIP_REF_RG28 = 28

Use RemoveGrain mode 28's result to constrain the pixel.

CLIP_REF_RG5 class-attribute instance-attribute

CLIP_REF_RG5 = 15

Use RemoveGrain mode 5's result to constrain the pixel.

CLIP_REF_RG6 class-attribute instance-attribute

CLIP_REF_RG6 = 16

Use RemoveGrain mode 6's result to constrain the pixel.

LINE_CLIP_CLOSE class-attribute instance-attribute

LINE_CLIP_CLOSE = 9

Line-sensitive clamp using the closest neighbors.

LINE_CLIP_LIGHT class-attribute instance-attribute

LINE_CLIP_LIGHT = 6

Line-sensitive clamping with a light effect.

LINE_CLIP_MEDIUM class-attribute instance-attribute

LINE_CLIP_MEDIUM = 7

Line-sensitive clamping with a moderate effect.

LINE_CLIP_MIN class-attribute instance-attribute

LINE_CLIP_MIN = 5

Line-sensitive clamping with minimal alteration.

LINE_CLIP_STRONG class-attribute instance-attribute

LINE_CLIP_STRONG = 8

Line-sensitive clamping with a strong effect.

MINMAX_SQUARE1 class-attribute instance-attribute

MINMAX_SQUARE1 = 1

Clamp using the 1st min/max from a 3x3 square in the reference clip.

MINMAX_SQUARE2 class-attribute instance-attribute

MINMAX_SQUARE2 = 2

Clamp using the 2nd min/max from a 3x3 square in the reference clip.

MINMAX_SQUARE3 class-attribute instance-attribute

MINMAX_SQUARE3 = 3

Clamp using the 3rd min/max from a 3x3 square in the reference clip.

MINMAX_SQUARE4 class-attribute instance-attribute

MINMAX_SQUARE4 = 4

Clamp using the 4th min/max from a 3x3 square in the reference clip.

MINMAX_SQUARE_REF1 class-attribute instance-attribute

MINMAX_SQUARE_REF1 = 11

Same as mode 1, but clips with min/max of 1st rank and the center pixel of the reference clip.

MINMAX_SQUARE_REF2 class-attribute instance-attribute

MINMAX_SQUARE_REF2 = 12

Same as mode 2, but clips with min/max of 2nd rank and the center pixel of the reference clip.

MINMAX_SQUARE_REF3 class-attribute instance-attribute

MINMAX_SQUARE_REF3 = 13

Same as mode 3, but clips with min/max of 3rd rank and the center pixel of the reference clip.

MINMAX_SQUARE_REF4 class-attribute instance-attribute

MINMAX_SQUARE_REF4 = 14

Same as mode 4, but clips with min/max of 4th rank and the center pixel of the reference clip.

MINMAX_SQUARE_REF_CLOSE class-attribute instance-attribute

MINMAX_SQUARE_REF_CLOSE = 10

Replace pixel with the closest value in the 3x3 reference square.

NONE class-attribute instance-attribute

NONE = 0

No repair. The input plane is passed through unchanged.

__call__

__call__(
    clip: VideoNode, repairclip: VideoNode, planes: PlanesT = None
) -> ConstantFormatVideoNode

Apply the selected repair mode to a clip using a repairclip.

Parameters:

  • clip
    (VideoNode) –

    Input clip to process (typically filtered).

  • repairclip
    (VideoNode) –

    Reference clip for bounds (often the original or a less-processed version).

  • planes
    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Clip with repaired pixels, bounded by the reference.

Source code
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
def __call__(
    self, clip: vs.VideoNode, repairclip: vs.VideoNode, planes: PlanesT = None
) -> ConstantFormatVideoNode:
    """
    Apply the selected repair mode to a `clip` using a `repairclip`.

    Args:
        clip: Input clip to process (typically filtered).
        repairclip: Reference clip for bounds (often the original or a less-processed version).
        planes: Planes to process. Defaults to all.

    Returns:
        Clip with repaired pixels, bounded by the reference.
    """
    return repair(clip, repairclip, self, planes)

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
26
27
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
    return self._func(*args, **kwargs)

VerticalCleaner

VerticalCleaner(vertical_cleaner_func: Callable[P, R])

Bases: Generic[P, R]

Class decorator that wraps the vertical_cleaner function and extends its functionality.

It is not meant to be used directly.

Classes:

  • Mode

    Enum that specifies the vertical cleaner mode to use

Methods:

Source code
602
603
def __init__(self, vertical_cleaner_func: Callable[P, R]) -> None:
    self._func = vertical_cleaner_func

Mode

Bases: CustomIntEnum

Enum that specifies the vertical cleaner mode to use in the zsmooth plugin.

Methods:

  • __call__

    Applies the vertical cleaning mode to the given clip.

Attributes:

  • MEDIAN

    Applies a strict vertical median filter.

  • NONE

    The input plane is simply passed through.

  • PRESERVING

    Applies a detail-preserving vertical median filter (less aggressive).

MEDIAN class-attribute instance-attribute

MEDIAN = 1

Applies a strict vertical median filter.

NONE class-attribute instance-attribute

NONE = 0

The input plane is simply passed through.

PRESERVING class-attribute instance-attribute

PRESERVING = 2

Applies a detail-preserving vertical median filter (less aggressive).

__call__

__call__(clip: VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode

Applies the vertical cleaning mode to the given clip.

Parameters:

  • clip
    (VideoNode) –

    Source clip to process.

  • planes
    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Filtered clip.

Source code
629
630
631
632
633
634
635
636
637
638
639
640
def __call__(self, clip: vs.VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode:
    """
    Applies the vertical cleaning mode to the given clip.

    Args:
        clip: Source clip to process.
        planes: Planes to process. Defaults to all.

    Returns:
        Filtered clip.
    """
    return vertical_cleaner(clip, self, planes)

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
605
606
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
    return self._func(*args, **kwargs)

clense

clense(
    clip: VideoNode,
    previous_clip: VideoNode | None = None,
    next_clip: VideoNode | None = None,
    mode: Mode | str = NONE,
    planes: PlanesT = None,
) -> ConstantFormatVideoNode

Apply a clense (temporal median) filter based on the specified mode.

Example
clensed = clense(clip, ..., mode=clense.Mode.BOTH)

Alternatively, directly using the enum:

clensed = clense.Mode.BOTH(clip, ...)

Parameters:

  • clip

    (VideoNode) –

    Source clip to process.

  • previous_clip

    (VideoNode | None, default: None ) –

    Optional alternate clip to source previous frames. Defaults to clip.

  • next_clip

    (VideoNode | None, default: None ) –

    Optional alternate clip to source next frames. Defaults to clip.

  • mode

    (Mode | str, default: NONE ) –

    Mode of filtering. One of Mode or its string values.

  • planes

    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Clensed clip with temporal median filtering.

Source code
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
@Clense
def clense(
    clip: vs.VideoNode,
    previous_clip: vs.VideoNode | None = None,
    next_clip: vs.VideoNode | None = None,
    mode: Clense.Mode | str = Clense.Mode.NONE,
    planes: PlanesT = None,
) -> ConstantFormatVideoNode:
    """
    Apply a clense (temporal median) filter based on the specified mode.

    Example:
        ```py
        clensed = clense(clip, ..., mode=clense.Mode.BOTH)
        ```

        Alternatively, directly using the enum:
        ```py
        clensed = clense.Mode.BOTH(clip, ...)
        ```

    Args:
        clip: Source clip to process.
        previous_clip: Optional alternate clip to source previous frames. Defaults to `clip`.
        next_clip: Optional alternate clip to source next frames. Defaults to `clip`.
        mode: Mode of filtering. One of [Mode][vsrgtools.rgtools.Clense.Mode] or its string values.
        planes: Planes to process. Defaults to all.

    Returns:
        Clensed clip with temporal median filtering.
    """
    assert check_variable(clip, clense)

    kwargs = KwargsNotNone(previous=previous_clip, next=next_clip)

    if mode == Clense.Mode.NONE:
        return clip

    return getattr(clip.zsmooth, mode)(planes=planes, **kwargs)

remove_grain

remove_grain(
    clip: VideoNode,
    mode: int | Mode | Sequence[int | Mode],
    planes: PlanesT = None,
) -> ConstantFormatVideoNode

Apply spatial denoising using the RemoveGrain algorithm.

Supports a variety of pixel clamping, edge-aware filtering, and blur strategies. See RemoveGrain.Mode for all available modes.

  • Modes 1-24 are natively implemented in zsmooth.RemoveGrain.
  • Modes 25+ fall back to expression-based implementations.
Example
denoised = remove_grain(clip, remove_grain.Mode.EDGE_CLIP_STRONG)

Alternatively, directly using the enum:

denoised = remove_grain.Mode.EDGE_CLIP_STRONG(clip)

Parameters:

  • clip

    (VideoNode) –

    Clip to process.

  • mode

    (int | Mode | Sequence[int | Mode]) –

    Mode(s) to use. Can be a single mode or per-plane list. See RemoveGrain.Mode for details.

  • planes

    (PlanesT, default: None ) –

    Planes to process. Default to all.

Returns:

  • ConstantFormatVideoNode

    Processed (denoised) clip.

Source code
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
@RemoveGrain
def remove_grain(
    clip: vs.VideoNode, mode: int | RemoveGrain.Mode | Sequence[int | RemoveGrain.Mode], planes: PlanesT = None
) -> ConstantFormatVideoNode:
    """
    Apply spatial denoising using the RemoveGrain algorithm.

    Supports a variety of pixel clamping, edge-aware filtering, and blur strategies.
    See [RemoveGrain.Mode][vsrgtools.rgtools.RemoveGrain.Mode] for all available modes.

    - Modes 1-24 are natively implemented in [zsmooth.RemoveGrain](https://github.com/adworacz/zsmooth?tab=readme-ov-file#removegrain).
    - Modes 25+ fall back to expression-based implementations.

    Example:
        ```py
        denoised = remove_grain(clip, remove_grain.Mode.EDGE_CLIP_STRONG)
        ```

        Alternatively, directly using the enum:
        ```py
        denoised = remove_grain.Mode.EDGE_CLIP_STRONG(clip)
        ```

    Args:
        clip: Clip to process.
        mode: Mode(s) to use. Can be a single mode or per-plane list. See
            [RemoveGrain.Mode][vsrgtools.rgtools.RemoveGrain.Mode] for details.
        planes: Planes to process. Default to all.

    Returns:
        Processed (denoised) clip.
    """
    assert check_variable(clip, remove_grain)

    mode = normalize_param_planes(clip, mode, planes, RemoveGrain.Mode.NONE)

    if not sum(mode):
        return clip

    if all(m in range(24 + 1) for m in mode):
        return clip.zsmooth.RemoveGrain(mode)

    return norm_expr(clip, tuple([removegrain_aka_exprs[m]() for m in mode]), func=remove_grain)

repair

repair(
    clip: VideoNode,
    repairclip: VideoNode,
    mode: int | Mode | Sequence[int | Mode],
    planes: PlanesT = None,
) -> ConstantFormatVideoNode

Constrains the input clip using a repairclip by clamping pixel values based on a chosen mode.

This is typically used to limit over-aggressive filtering (e.g., from RemoveGrain) while keeping the corrections within reasonable bounds derived from the reference (repairclip). Often used in detail restoration workflows.

  • Modes 1-24 directly map to zsmooth.Repair plugin modes.
  • Modes 26+ fall back to expression-based implementations.
Example
repaired = repair(filtered, clip, repair.Mode.MINMAX_SQUARE_REF3)

Alternatively, directly using the enum:

repaired = repair.Mode.MINMAX_SQUARE_REF3(clip)

Parameters:

  • clip

    (VideoNode) –

    Input clip to process (typically filtered).

  • repairclip

    (VideoNode) –

    Reference clip for bounds (often the original or a less-processed version).

  • mode

    (int | Mode | Sequence[int | Mode]) –

    Repair mode(s) used to constrain pixels. Can be a single mode or a list per plane. See Repair.Mode for details.

  • planes

    (PlanesT, default: None ) –

    Planes to process. Default to all.

Returns:

  • ConstantFormatVideoNode

    Clip with repaired pixels, bounded by the reference.

Source code
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
@Repair
def repair(
    clip: vs.VideoNode,
    repairclip: vs.VideoNode,
    mode: int | Repair.Mode | Sequence[int | Repair.Mode],
    planes: PlanesT = None,
) -> ConstantFormatVideoNode:
    """
    Constrains the input `clip` using a `repairclip` by clamping pixel values
    based on a chosen [mode][vsrgtools.rgtools.Repair.Mode].

    This is typically used to limit over-aggressive filtering (e.g., from `RemoveGrain`) while keeping
    the corrections within reasonable bounds derived from the reference (`repairclip`). Often used in detail
    restoration workflows.

    - Modes 1-24 directly map to [zsmooth.Repair](https://github.com/adworacz/zsmooth?tab=readme-ov-file#repair)
      plugin modes.
    - Modes 26+ fall back to expression-based implementations.

    Example:
        ```py
        repaired = repair(filtered, clip, repair.Mode.MINMAX_SQUARE_REF3)
        ```

        Alternatively, directly using the enum:
        ```py
        repaired = repair.Mode.MINMAX_SQUARE_REF3(clip)
        ```

    Args:
        clip: Input clip to process (typically filtered).
        repairclip: Reference clip for bounds (often the original or a less-processed version).
        mode: Repair mode(s) used to constrain pixels. Can be a single mode or a list per plane. See
            [Repair.Mode][vsrgtools.rgtools.Repair.Mode] for details.
        planes: Planes to process. Default to all.

    Returns:
        Clip with repaired pixels, bounded by the reference.
    """
    assert check_variable(clip, repair)
    assert check_variable(repairclip, repair)

    mode = normalize_param_planes(clip, mode, planes, Repair.Mode.NONE)

    if not sum(mode):
        return clip

    if all(m in range(24 + 1) for m in mode):
        return clip.zsmooth.Repair(repairclip, mode)

    return norm_expr([clip, repairclip], tuple([repair_aka_exprs[m]() for m in mode]), func=repair)

vertical_cleaner

vertical_cleaner(
    clip: VideoNode,
    mode: int | Mode | Sequence[int | Mode],
    planes: PlanesT = None,
) -> ConstantFormatVideoNode

Applies a fast vertical median or relaxed median filter to the clip using the zsmooth plugin.

Example
cleaned = vertical_cleaner(clip, vertical_cleaner.Mode.PRESERVING)

Alternatively, directly using the enum:

cleaned = vertical_cleaner.Mode.PRESERVING(clip)

Parameters:

  • clip

    (VideoNode) –

    Source clip to process.

  • mode

    (int | Mode | Sequence[int | Mode]) –

    Mode of vertical cleaning to apply. Can be:

    • A single enum/int (applied to all planes),
    • A sequence of enums/ints (one per plane).
  • planes

    (PlanesT, default: None ) –

    Planes to process. Defaults to all.

Returns:

  • ConstantFormatVideoNode

    Filtered clip.

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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
@VerticalCleaner
def vertical_cleaner(
    clip: vs.VideoNode,
    mode: int | VerticalCleaner.Mode | Sequence[int | VerticalCleaner.Mode],
    planes: PlanesT = None,
) -> ConstantFormatVideoNode:
    """
    Applies a fast vertical median or relaxed median filter to the clip
    using the [zsmooth](https://github.com/adworacz/zsmooth?tab=readme-ov-file#verticalcleaner) plugin.

    Example:
        ```py
        cleaned = vertical_cleaner(clip, vertical_cleaner.Mode.PRESERVING)
        ```

        Alternatively, directly using the enum:
        ```py
        cleaned = vertical_cleaner.Mode.PRESERVING(clip)
        ```

    Args:
        clip: Source clip to process.
        mode: Mode of vertical cleaning to apply.
            Can be:

               - A single enum/int (applied to all planes),
               - A sequence of enums/ints (one per plane).

        planes: Planes to process. Defaults to all.

    Returns:
        Filtered clip.
    """
    assert check_variable(clip, vertical_cleaner)

    mode = normalize_param_planes(clip, mode, planes, VerticalCleaner.Mode.NONE)

    if not sum(mode):
        return clip

    return clip.zsmooth.VerticalCleaner(mode)