Skip to content

masks

Functions:

range_mask

range_mask(
    clip: VideoNode, rad: int = 2, radc: int = 0
) -> ConstantFormatVideoNode
Source code
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
@limiter
def range_mask(clip: vs.VideoNode, rad: int = 2, radc: int = 0) -> ConstantFormatVideoNode:
    assert check_variable(clip, range_mask)

    def _minmax(clip: vs.VideoNode, iters: int, maxx: bool) -> vs.VideoNode:
        func = Morpho.maximum if maxx else Morpho.minimum

        for i in range(1, iters + 1):
            clip = func(clip, coordinates=Coordinates.from_iter(i))

        return clip

    return join([
        ExprOp.SUB.combine(
            _minmax(plane, r, True),
            _minmax(plane, r, False)
        ) for plane, r in zip(
            split(clip), normalize_seq(radc and [rad, radc] or rad, clip.format.num_planes)
        )
    ])