Skip to content

util

RModeT module-attribute

RModeT = TypeVar('RModeT', RemoveGrainMode, RepairMode)

mean_matrix module-attribute

mean_matrix = list(MEAN(1, mode=SQUARE))

wmean_matrix module-attribute

wmean_matrix = list(BINOMIAL(1, mode=SQUARE))

norm_rmode_planes

norm_rmode_planes(
    clip: VideoNode,
    mode: int | RModeT | Sequence[int | RModeT],
    planes: PlanesT = None,
) -> list[int]
Source code
24
25
26
27
28
29
30
31
32
33
34
35
def norm_rmode_planes(
    clip: vs.VideoNode, mode: int | RModeT | Sequence[int | RModeT], planes: PlanesT = None
) -> list[int]:
    assert check_variable(clip, norm_rmode_planes)

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

    planes = normalize_planes(clip, planes)

    return [
        cast(RModeT, rep if i in planes else 0) for i, rep in enumerate(modes_array, 0)
    ]

normalize_radius

normalize_radius(
    clip: VideoNode,
    func: GenericVSFunction,
    radius: list[Nb] | tuple[str, list[Nb]],
    planes: list[int],
    **kwargs: Any
) -> VideoNode
Source code
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def normalize_radius(
    clip: vs.VideoNode, func: GenericVSFunction, radius: list[Nb] | tuple[str, list[Nb]],
    planes: list[int], **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, normalize_radius)

    name, radius = radius if isinstance(radius, tuple) else ('radius', radius)

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

    def _get_kwargs(rad: Nb) -> KwargsT:
        return kwargs | {name: rad, 'planes': planes}

    if len(set(radius)) > 0:
        if len(planes) != 1:
            return join([
                func(plane(clip, i), **_get_kwargs(rad)) for i, rad in enumerate(radius)
            ])

        radius_i = radius[planes[0]]
    else:
        radius_i = radius[0]

    return func(clip, **_get_kwargs(radius_i))