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
365
366
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
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.

    :param clip:             Source clip to process.
    :param previous_clip:    Optional alternate clip to source previous frames. Defaults to `clip`.
    :param next_clip:        Optional alternate clip to source next frames. Defaults to `clip`.
    :param planes:           Planes to process. Defaults to all.
    :return:                 Clensed clip with temporal median filtering.
    """
    return clense(clip, previous_clip, next_clip, self, planes)

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
368
369
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
197
198
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 3×3 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 3×3 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 3×3 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 3×3 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 3×3 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 3×3 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
303
304
305
306
307
308
309
310
311
312
313
def __call__(self, clip: vs.VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode:
    """
    Apply the selected remove grain mode to a `clip`.

    :param clip:            Clip to process.
    :param planes:          Planes to process. Defaults to all.
    :return:                Processed (denoised) clip.
    """
    from .util import norm_rmode_planes

    return remove_grain(clip, norm_rmode_planes(clip, self, planes))

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
200
201
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
26
27
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 3×3 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 3×3 square in the reference clip.

  • MINMAX_SQUARE2

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

  • MINMAX_SQUARE3

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

  • MINMAX_SQUARE4

    Clamp using the 4th min/max from a 3×3 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 3×3 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 3×3 square in the reference clip.

MINMAX_SQUARE2 class-attribute instance-attribute

MINMAX_SQUARE2 = 2

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

MINMAX_SQUARE3 class-attribute instance-attribute

MINMAX_SQUARE3 = 3

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

MINMAX_SQUARE4 class-attribute instance-attribute

MINMAX_SQUARE4 = 4

Clamp using the 4th min/max from a 3×3 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 3×3 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def __call__(
    self, clip: vs.VideoNode, repairclip: vs.VideoNode, planes: PlanesT = None
) -> ConstantFormatVideoNode:
    """
    Apply the selected repair mode to a `clip` using a `repairclip`.

    :param clip:            Input clip to process (typically filtered).
    :param repairclip:      Reference clip for bounds (often the original or a less-processed version).
    :param planes:          Planes to process. Defaults to all.
    :return:                Clip with repaired pixels, bounded by the reference.
    """
    from .util import norm_rmode_planes

    return repair(clip, repairclip, norm_rmode_planes(clip, self, planes))

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
29
30
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
459
460
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
480
481
482
483
484
485
486
487
488
489
def __call__(self, clip: vs.VideoNode, planes: PlanesT = None) -> ConstantFormatVideoNode:
    """
    Applies the vertical cleaning mode to the given clip.

    :param clip:        Source clip to process.
    :param planes:      Planes to process. Defaults to all.
    :return:            Filtered clip.
    """
    from .util import norm_rmode_planes
    return vertical_cleaner(clip, norm_rmode_planes(clip, self, planes))

__call__

__call__(*args: args, **kwargs: kwargs) -> R
Source code
462
463
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:
```py
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
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
@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, ...)
        ```

    :param clip:             Source clip to process.
    :param previous_clip:    Optional alternate clip to source previous frames. Defaults to `clip`.
    :param next_clip:        Optional alternate clip to source next frames. Defaults to `clip`.
    :param mode:             Mode of filtering. One of [Mode][vsrgtools.rgtools.Clense.Mode] or its string values.
    :param planes:           Planes to process. Defaults to all.
    :return:                 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]
) -> 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:
```py
denoised = remove_grain.Mode.EDGE_CLIP_STRONG(clip)
```

Parameters:

Returns:

  • ConstantFormatVideoNode

    Processed (denoised) clip.

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
@RemoveGrain
def remove_grain(
    clip: vs.VideoNode, mode: int | RemoveGrain.Mode | Sequence[int | RemoveGrain.Mode]
) -> 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)
        ```

    :param clip:    Clip to process.
    :param mode:    Mode(s) to use. Can be a single mode or per-plane list.
                    See [RemoveGrain.Mode][vsrgtools.rgtools.RemoveGrain.Mode] for details.
    :return:        Processed (denoised) clip.
    """
    assert check_variable(clip, remove_grain)

    mode = normalize_seq(mode, clip.format.num_planes)

    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],
) -> 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:
```py
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.

Returns:

  • ConstantFormatVideoNode

    Clip with repaired pixels, bounded by the reference.

Source code
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@Repair
def repair(
    clip: vs.VideoNode, repairclip: vs.VideoNode, mode: int | Repair.Mode | Sequence[int | Repair.Mode]
) -> 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)
        ```

    :param clip:          Input clip to process (typically filtered).
    :param repairclip:    Reference clip for bounds (often the original or a less-processed version).
    :param 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.
    :return:              Clip with repaired pixels, bounded by the reference.
    """
    assert check_variable(clip, repair)
    assert check_variable(repairclip, repair)

    mode = normalize_seq(mode, clip.format.num_planes)

    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]
) -> 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:
```py
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).

Returns:

  • ConstantFormatVideoNode

    Filtered clip.

Source code
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
@VerticalCleaner
def vertical_cleaner(
    clip: vs.VideoNode, mode: int | VerticalCleaner.Mode | Sequence[int | VerticalCleaner.Mode]
) -> 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)
        ```

    :param clip:    Source clip to process.
    :param 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).
    :return:        Filtered clip.
    """
    assert check_variable(clip, vertical_cleaner)

    mode = normalize_seq(mode, clip.format.num_planes)

    if not sum(mode):
        return clip

    return clip.zsmooth.VerticalCleaner(mode)