Skip to content

edge

Classes:

  • ASobel

    Modified Sobel-Feldman operator from AWarpSharp.

  • Cross

    "HotDoG" Operator from AVS ExTools by Dogway.

  • EdgeDetect

    Abstract edge detection interface.

  • EuclideanDistance
  • ExKirsch

    Extended Russell Kirsch compass operator. 5x5 matrices.

  • ExLaplacian1

    Extended Pierre-Simon de Laplace operator, 1st implementation.

  • ExLaplacian2

    Extended Pierre-Simon de Laplace operator, 2nd implementation.

  • ExLaplacian3

    Extended Pierre-Simon de Laplace operator, 3rd implementation.

  • ExLaplacian4

    Extended Pierre-Simon de Laplace operator, 4th implementation.

  • ExPrewitt

    Extended Judith M. S. Prewitt operator.

  • ExSobel

    Extended Sobel-Feldman operator.

  • FDoG

    Flow-based Difference of Gaussian

  • FDoGTCanny

    Flow-based Difference of Gaussian TCanny Vapoursynth plugin.

  • Farid

    Farid & Simoncelli operator.

  • FreyChen

    Chen Frei operator. 3x3 matrices properly implemented.

  • FreyChenG41

    "Chen Frei" operator. 3x3 matrices from G41Fun.

  • Kayyali

    Kayyali operator.

  • Kirsch

    Russell Kirsch compass operator.

  • KirschTCanny

    Russell Kirsch compass TCanny Vapoursynth plugin operator.

  • Kroon

    Dirk-Jan Kroon operator.

  • KroonTCanny

    Dirk-Jan Kroon TCanny Vapoursynth plugin operator.

  • Laplacian1

    Pierre-Simon de Laplace operator 1st implementation.

  • Laplacian2

    Pierre-Simon de Laplace operator 2nd implementation.

  • Laplacian3

    Pierre-Simon de Laplace operator 3rd implementation.

  • Laplacian4

    Pierre-Simon de Laplace operator 4th implementation.

  • LoG

    Laplacian of Gaussian operator.

  • MagDirection

    Direction of magnitude calculation.

  • MagnitudeMatrix
  • Matrix1D
  • Matrix3x3
  • Matrix5x5
  • MatrixEdgeDetect
  • Max
  • MinMax

    Min/max mask with separate luma/chroma radii.

  • Prewitt

    Judith M. S. Prewitt operator.

  • PrewittStd

    Judith M. S. Prewitt Vapoursynth plugin operator.

  • PrewittTCanny

    Judith M. S. Prewitt TCanny plugin operator.

  • RScharr

    Refined H. Scharr operator to more accurately calculate

  • RidgeDetect
  • Robinson3

    Robinson compass operator level 3.

  • Robinson5

    Robinson compass operator level 5.

  • Scharr

    Original H. Scharr optimised operator which attempts

  • ScharrTCanny

    H. Scharr optimised TCanny Vapoursynth plugin operator.

  • SingleMatrix
  • Sobel

    Sobel-Feldman operator.

  • SobelStd

    Sobel-Feldman Vapoursynth plugin operator.

  • SobelTCanny

    Sobel-Feldman Vapoursynth plugin operator.

  • TEdge

    (TEdgeMasktype=2) Avisynth plugin.

  • TEdgeTedgemask

    (tedgemask.TEdgeMask(threshold=0.0, type=2)) Vapoursynth plugin.

  • TheToof

    TheToof compass operator from SharpAAMCmod.

  • Tritical

    Operator used in Tritical's original TCanny filter.

  • TriticalTCanny

    Operator used in Tritical's original TCanny filter.

Functions:

Attributes:

EdgeDetectT module-attribute

EdgeDetectT: TypeAlias = type[EdgeDetect] | EdgeDetect | str

RidgeDetectT module-attribute

RidgeDetectT: TypeAlias = type[RidgeDetect] | RidgeDetect | str

ASobel

ASobel(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Modified Sobel-Feldman operator from AWarpSharp.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Cross

Cross(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

"HotDoG" Operator from AVS ExTools by Dogway. Plain and simple cross first order derivative.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, 0, 0, 0, 0, 0, 0, 0, -1],
    [0, 0, -1, 0, 0, 0, 1, 0, 0],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

EdgeDetect

EdgeDetect(**kwargs: Any)

Bases: ABC

Abstract edge detection interface.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

EuclideanDistance

EuclideanDistance(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExKirsch

ExKirsch(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MagnitudeMatrix, Max

Extended Russell Kirsch compass operator. 5x5 matrices.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        9,
        9,
        9,
        9,
        9,
        9,
        5,
        5,
        5,
        9,
        -7,
        -3,
        0,
        -3,
        -7,
        -7,
        -3,
        -3,
        -3,
        -7,
        -7,
        -7,
        -7,
        -7,
        -7,
    ],
    [
        9,
        9,
        9,
        9,
        -7,
        9,
        5,
        5,
        -3,
        -7,
        9,
        5,
        0,
        -3,
        -7,
        9,
        -3,
        -3,
        -3,
        -7,
        -7,
        -7,
        -7,
        -7,
        -7,
    ],
    [
        9,
        9,
        -7,
        -7,
        -7,
        9,
        5,
        -3,
        -3,
        -7,
        9,
        5,
        0,
        -3,
        -7,
        9,
        5,
        -3,
        -3,
        -7,
        9,
        9,
        -7,
        -7,
        -7,
    ],
    [
        -7,
        -7,
        -7,
        -7,
        -7,
        9,
        -3,
        -3,
        -3,
        -7,
        9,
        5,
        0,
        -3,
        -7,
        9,
        5,
        5,
        -3,
        -7,
        9,
        9,
        9,
        9,
        -7,
    ],
    [
        -7,
        -7,
        -7,
        -7,
        -7,
        -7,
        -3,
        -3,
        -3,
        -7,
        -7,
        -3,
        0,
        -3,
        -7,
        9,
        5,
        5,
        5,
        9,
        9,
        9,
        9,
        9,
        9,
    ],
    [
        -7,
        -7,
        -7,
        -7,
        -7,
        -7,
        -3,
        -3,
        -3,
        9,
        -7,
        -3,
        0,
        5,
        9,
        -7,
        -3,
        5,
        5,
        9,
        -7,
        9,
        9,
        9,
        9,
    ],
    [
        -7,
        -7,
        -7,
        9,
        9,
        -7,
        -3,
        -3,
        5,
        9,
        -7,
        -3,
        0,
        5,
        9,
        -7,
        -3,
        -3,
        5,
        9,
        -7,
        -7,
        -7,
        9,
        9,
    ],
    [
        -7,
        9,
        9,
        9,
        9,
        -7,
        -3,
        5,
        5,
        9,
        -7,
        -3,
        0,
        5,
        9,
        -7,
        -3,
        -3,
        -3,
        9,
        -7,
        -7,
        -7,
        -7,
        -7,
    ],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExLaplacian1

ExLaplacian1(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Extended Pierre-Simon de Laplace operator, 1st implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        0,
        0,
        -1,
        0,
        0,
        0,
        0,
        -1,
        0,
        0,
        -1,
        -1,
        8,
        -1,
        -1,
        0,
        0,
        -1,
        0,
        0,
        0,
        0,
        -1,
        0,
        0,
    ]
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExLaplacian2

ExLaplacian2(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Extended Pierre-Simon de Laplace operator, 2nd implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        0,
        1,
        -1,
        1,
        0,
        1,
        1,
        -4,
        1,
        1,
        -1,
        -4,
        8,
        -4,
        -1,
        1,
        1,
        -4,
        1,
        1,
        0,
        1,
        -1,
        1,
        0,
    ]
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExLaplacian3

ExLaplacian3(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Extended Pierre-Simon de Laplace operator, 3rd implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        -1,
        1,
        -1,
        1,
        -1,
        1,
        2,
        -4,
        2,
        1,
        -1,
        -4,
        8,
        -4,
        -1,
        1,
        2,
        -4,
        2,
        1,
        -1,
        1,
        -1,
        1,
        -1,
    ]
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExLaplacian4

ExLaplacian4(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Extended Pierre-Simon de Laplace operator, 4th implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        24,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
        -1,
    ]
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

ExPrewitt

ExPrewitt(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix5x5

Extended Judith M. S. Prewitt operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
    ],
    [
        2,
        2,
        2,
        2,
        2,
        1,
        1,
        1,
        1,
        1,
        0,
        0,
        0,
        0,
        0,
        -1,
        -1,
        -1,
        -1,
        -1,
        -2,
        -2,
        -2,
        -2,
        -2,
    ],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ExSobel

ExSobel(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix5x5

Extended Sobel-Feldman operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
        4,
        2,
        0,
        -2,
        -4,
        2,
        1,
        0,
        -1,
        -2,
        2,
        1,
        0,
        -1,
        -2,
    ],
    [
        2,
        2,
        4,
        2,
        2,
        1,
        1,
        2,
        1,
        1,
        0,
        0,
        0,
        0,
        0,
        -1,
        -1,
        -2,
        -1,
        -1,
        -2,
        -2,
        -4,
        -2,
        -2,
    ],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

FDoG

FDoG(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix5x5

Flow-based Difference of Gaussian

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [2, 2]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        1,
        1,
        0,
        -1,
        -1,
        2,
        2,
        0,
        -2,
        -2,
        3,
        3,
        0,
        -3,
        -3,
        2,
        2,
        0,
        -2,
        -2,
        1,
        1,
        0,
        -1,
        -1,
    ],
    [
        1,
        2,
        3,
        2,
        1,
        1,
        2,
        3,
        2,
        1,
        0,
        0,
        0,
        0,
        0,
        -1,
        -2,
        -3,
        -2,
        -1,
        -1,
        -2,
        -3,
        -2,
        -1,
    ],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

FDoGTCanny

FDoGTCanny(**kwargs: Any)

Bases: Matrix5x5, EdgeDetect

Flow-based Difference of Gaussian TCanny Vapoursynth plugin.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Farid

Farid(**kwargs: Any)

Bases: NormalizeProcessor, RidgeDetect, EuclideanDistance, Matrix5x5

Farid & Simoncelli operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        0.004127602875174862,
        0.027308149775363867,
        0.04673225765917656,
        0.027308149775363867,
        0.004127602875174862,
        0.010419993699470744,
        0.06893849946536831,
        0.11797400212587895,
        0.06893849946536831,
        0.010419993699470744,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        -0.010419993699470744,
        -0.06893849946536831,
        -0.11797400212587895,
        -0.06893849946536831,
        -0.010419993699470744,
        -0.004127602875174862,
        -0.027308149775363867,
        -0.04673225765917656,
        -0.027308149775363867,
        -0.004127602875174862,
    ],
    [
        0.004127602875174862,
        0.010419993699470744,
        0.0,
        -0.010419993699470744,
        -0.004127602875174862,
        0.027308149775363867,
        0.06893849946536831,
        0.0,
        -0.06893849946536831,
        -0.027308149775363867,
        0.04673225765917656,
        0.11797400212587895,
        0.0,
        -0.11797400212587895,
        -0.04673225765917656,
        0.027308149775363867,
        0.06893849946536831,
        0.0,
        -0.06893849946536831,
        -0.027308149775363867,
        0.004127602875174862,
        0.010419993699470744,
        0.0,
        -0.010419993699470744,
        -0.004127602875174862,
    ],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

FreyChen

FreyChen(**kwargs: Any)

Bases: NormalizeProcessor, MatrixEdgeDetect

Chen Frei operator. 3x3 matrices properly implemented.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [
    2 * sqrt2,
    2 * sqrt2,
    2 * sqrt2,
    2 * sqrt2,
    2,
    2,
    6,
    6,
    3,
]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, sqrt2, 1, 0, 0, 0, -1, -sqrt2, -1],
    [1, 0, -1, sqrt2, 0, -sqrt2, 1, 0, -1],
    [0, -1, sqrt2, 1, 0, -1, -sqrt2, 1, 0],
    [sqrt2, -1, 0, -1, 0, 1, 0, 1, -sqrt2],
    [0, 1, 0, -1, 0, -1, 0, 1, 0],
    [-1, 0, 1, 0, 0, 0, 1, 0, -1],
    [1, -2, 1, -2, 4, -2, 1, -2, 1],
    [-2, 1, -2, 1, 4, 1, -2, 1, -2],
    [1, 1, 1, 1, 1, 1, 1, 1, 1],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

sqrt2 class-attribute instance-attribute

sqrt2 = sqrt(2)

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

FreyChenG41

FreyChenG41(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

"Chen Frei" operator. 3x3 matrices from G41Fun.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [7, 7]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [-7, 0, 7, -10, 0, 10, -7, 0, 7],
    [-7, -10, -7, 0, 0, 0, 7, 10, 7],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

Kayyali

Kayyali(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Kayyali operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [[6, 0, -6, 0, 0, 0, -6, 0, 6]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Kirsch

Kirsch(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MagnitudeMatrix, Max, Matrix3x3

Russell Kirsch compass operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [5, 5, 5, -3, 0, -3, -3, -3, -3],
    [5, 5, -3, 5, 0, -3, -3, -3, -3],
    [5, -3, -3, 5, 0, -3, 5, -3, -3],
    [-3, -3, -3, 5, 0, -3, 5, 5, -3],
    [-3, -3, -3, -3, 0, -3, 5, 5, 5],
    [-3, -3, -3, -3, 0, 5, -3, 5, 5],
    [-3, -3, 5, -3, 0, 5, -3, -3, 5],
    [-3, 5, 5, -3, 0, 5, -3, -3, -3],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

KirschTCanny

KirschTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Russell Kirsch compass TCanny Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Kroon

Kroon(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Dirk-Jan Kroon operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [17, 17]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [-17, 0, 17, -61, 0, 61, -17, 0, 17],
    [-17, -61, -17, 0, 0, 0, 17, 61, 17],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

KroonTCanny

KroonTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Dirk-Jan Kroon TCanny Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Laplacian1

Laplacian1(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 1st implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [[0, -1, 0, -1, 4, -1, 0, -1, 0]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Laplacian2

Laplacian2(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 2nd implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [[1, -2, 1, -2, 4, -2, 1, -2, 1]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Laplacian3

Laplacian3(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 3rd implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [[2, -1, 2, -1, -4, -1, 2, -1, 2]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Laplacian4

Laplacian4(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 4th implementation.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [[-1, -1, -1, -1, 8, -1, -1, -1, -1]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

LoG

LoG(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Laplacian of Gaussian operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [
        0,
        0,
        -1,
        0,
        0,
        0,
        -1,
        -2,
        -1,
        0,
        -1,
        -2,
        16,
        -2,
        -1,
        0,
        -1,
        -2,
        -1,
        0,
        0,
        0,
        -1,
        0,
        0,
    ]
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

MagDirection

Bases: IntFlag

Direction of magnitude calculation.

Methods:

Attributes:

ALL class-attribute instance-attribute

ALL = N | NW | W | SW | S | SE | E | NE

AXIS class-attribute instance-attribute

AXIS = N | W | S | E

CORNERS class-attribute instance-attribute

CORNERS = NW | SW | SE | NE

E class-attribute instance-attribute

E = auto()

EAST class-attribute instance-attribute

EAST = E | NE | SE

N class-attribute instance-attribute

N = auto()

NE class-attribute instance-attribute

NE = auto()

NORTH class-attribute instance-attribute

NORTH = N | NW | NE

NW class-attribute instance-attribute

NW = auto()

S class-attribute instance-attribute

S = auto()

SE class-attribute instance-attribute

SE = auto()

SOUTH class-attribute instance-attribute

SOUTH = S | SW | SE

SW class-attribute instance-attribute

SW = auto()

W class-attribute instance-attribute

W = auto()

WEST class-attribute instance-attribute

WEST = W | NW | SW

select_matrices

select_matrices(matrices: Sequence[T]) -> Sequence[T]
Source code in vsmasktools/edge/_abstract.py
80
81
82
83
84
85
86
def select_matrices(self, matrices: Sequence[T]) -> Sequence[T]:
    # In Python <3.11, composite flags are included in MagDirection's
    # collection and iteration interfaces.
    primary_flags = [flag for flag in MagDirection if flag != 0 and flag & (flag - 1) == 0]
    assert len(matrices) == len(primary_flags) and self

    return [matrix for flag, matrix in zip(primary_flags, matrices) if self & flag]

MagnitudeMatrix

MagnitudeMatrix(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MatrixEdgeDetect

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Matrix1D

Matrix1D(**kwargs: Any)

Bases: EdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Matrix3x3

Matrix3x3(**kwargs: Any)

Bases: EdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Matrix5x5

Matrix5x5(**kwargs: Any)

Bases: EdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

MatrixEdgeDetect

MatrixEdgeDetect(**kwargs: Any)

Bases: EdgeDetect

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Max

Max(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

MinMax

MinMax(rady: int = 2, radc: int = 0, **kwargs: Any)

Bases: EdgeDetect

Min/max mask with separate luma/chroma radii.

Methods:

Attributes:

Source code in vsmasktools/edge/_3x3.py
392
393
394
395
def __init__(self, rady: int = 2, radc: int = 0, **kwargs: Any) -> None:
    self.rady = rady
    self.radc = radc
    super().__init__(**kwargs)

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

radc instance-attribute

radc: int = radc

rady instance-attribute

rady: int = rady

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Prewitt

Prewitt(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Judith M. S. Prewitt operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, 0, -1, 1, 0, -1, 1, 0, -1],
    [1, 1, 1, 0, 0, 0, -1, -1, -1],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

PrewittStd

PrewittStd(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Judith M. S. Prewitt Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

PrewittTCanny

PrewittTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Judith M. S. Prewitt TCanny plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

RScharr

RScharr(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Refined H. Scharr operator to more accurately calculate 1st derivatives for a 3x3 kernel with coeffs 47 and 162.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [47, 47]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [-47, 0, 47, -162, 0, 162, -47, 0, 47],
    [-47, -162, -47, 0, 0, 0, 47, 162, 47],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

RidgeDetect

RidgeDetect(**kwargs: Any)

Bases: MatrixEdgeDetect

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

Robinson3

Robinson3(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MagnitudeMatrix, Max, Matrix3x3

Robinson compass operator level 3.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, 1, 1, 0, 0, 0, -1, -1, -1],
    [1, 1, 0, 1, 0, -1, 0, -1, -1],
    [1, 0, -1, 1, 0, -1, 1, 0, -1],
    [0, -1, -1, 1, 0, -1, 1, 1, 0],
    [],
    [],
    [],
    [],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Robinson5

Robinson5(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MagnitudeMatrix, Max, Matrix3x3

Robinson compass operator level 5.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, 2, 1, 0, 0, 0, -1, -2, -1],
    [2, 1, 0, 1, 0, -1, 0, -1, -2],
    [1, 0, -1, 2, 0, -2, 1, 0, -1],
    [0, -1, -2, 1, 0, -1, 2, 1, 0],
    [],
    [],
    [],
    [],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Scharr

Scharr(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Original H. Scharr optimised operator which attempts to achieve the perfect rotational symmetry with coefficients 3 and 10.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [3, 3]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [-3, 0, 3, -10, 0, 10, -3, 0, 3],
    [-3, -10, -3, 0, 0, 0, 3, 10, 3],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ScharrTCanny

ScharrTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

H. Scharr optimised TCanny Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

SingleMatrix

SingleMatrix(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Sobel

Sobel(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Sobel-Feldman operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [1, 0, -1, 2, 0, -2, 1, 0, -1],
    [1, 2, 1, 0, 0, 0, -1, -2, -1],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

SobelStd

SobelStd(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Sobel-Feldman Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

SobelTCanny

SobelTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Sobel-Feldman Vapoursynth plugin operator.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

TEdge

TEdge(**kwargs: Any)

Bases: EuclideanDistance, Matrix1D

(TEdgeMasktype=2) Avisynth plugin.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = [62, 62]

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [12, -74, 0, 74, -12],
    [-12, 74, 0, -74, 12],
]

mode_types class-attribute

mode_types: Sequence[str] | None = ['h', 'v']

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

TEdgeTedgemask

TEdgeTedgemask(**kwargs: Any)

Bases: Matrix1D, EdgeDetect

(tedgemask.TEdgeMask(threshold=0.0, type=2)) Vapoursynth plugin.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

TheToof

TheToof(mag_directions: MagDirection = ALL, **kwargs: Any)

Bases: MagnitudeMatrix, Max, Matrix3x3

TheToof compass operator from SharpAAMCmod.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
321
322
323
324
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = [4] * 4

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [5, 10, 5, 0, 0, 0, -5, -10, -5],
    [10, 5, 0, 5, 0, -5, 0, -5, -10],
    [5, 0, -5, 10, 0, -10, 5, 0, -5],
    [0, -5, -10, 5, 0, -5, 10, 5, 0],
    [],
    [],
    [],
    [],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

Tritical

Tritical(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

Operator used in Tritical's original TCanny filter. Plain and simple orthogonal first order derivative.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [0, 0, 0, -1, 0, 1, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0, -1, 0],
]

mode_types class-attribute

mode_types: Sequence[str] | None = None

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
394
395
396
397
398
399
400
401
@classmethod
def ensure_obj(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

from_param classmethod

from_param(
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
385
386
387
388
389
390
391
392
@classmethod
def from_param(
    cls,
    ridge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, ridge_detect, UnknownRidgeDetectError, [], func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> VideoNode

Makes ridge mask based on convolution kernel.

The resulting mask can be thresholded with lthr, hthr and multiplied with multi. Using a 32-bit float clip is recommended.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    clamp: Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
@inject_self
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Makes ridge mask based on convolution kernel.

    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.
    Using a 32-bit float clip is recommended.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """

    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess_ridge(clip)

    mask = self._compute_ridge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess_ridge(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

TriticalTCanny

TriticalTCanny(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

Operator used in Tritical's original TCanny filter. Plain and simple orthogonal first order derivative.

Methods:

Attributes:

Source code in vsmasktools/edge/_abstract.py
147
148
149
150
def __init__(self, **kwargs: Any) -> None:
    super().__init__()

    self.kwargs = kwargs

kwargs class-attribute instance-attribute

kwargs: KwargsT | None = kwargs

depth_scale classmethod

depth_scale(
    clip: VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode
Source code in vsmasktools/edge/_abstract.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@classmethod
def depth_scale(
    cls, clip: vs.VideoNode, bitdepth: VideoFormatT | HoldsVideoFormatT | int
) -> ConstantFormatVideoNode:
    assert check_variable(clip, cls)

    fmt = get_video_format(bitdepth)

    if fmt.sample_type == vs.INTEGER:
        return norm_expr(
            clip,
            ("x abs {peak} *", "x abs {peak} * neutral -"),
            format=fmt,
            peak=get_peak_value(bitdepth),
        )
    return clip

edgemask

edgemask(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> ConstantFormatVideoNode

Makes edge mask based on convolution kernel. The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

Parameters:

  • clip

    (VideoNode) –

    Source clip

  • lthr

    (float, default: 0.0 ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | None, default: None ) –

    High threshold. Anything above hthr will be set to the range max

  • multi

    (float, default: 1.0 ) –

    Multiply all pixels by this before thresholding

  • clamp

    (bool | tuple[float, float] | list[tuple[float, float]], default: False ) –

    Clamp to legal values if True or specified range (low, high)

  • planes

    (PlanesT, default: None ) –

    Which planes to process.

Returns:

  • ConstantFormatVideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
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
187
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> ConstantFormatVideoNode:
    """
    Makes edge mask based on convolution kernel.
    The resulting mask can be thresholded with lthr, hthr and multiplied with multi.

    Args:
        clip: Source clip
        lthr: Low threshold. Anything below lthr will be set to 0
        hthr: High threshold. Anything above hthr will be set to the range max
        multi: Multiply all pixels by this before thresholding
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        Mask clip
    """
    assert check_variable(clip, self.__class__)

    clip_p = self._preprocess(clip)

    mask = self._compute_edge_mask(clip_p, planes=planes, **kwargs)

    mask = self._postprocess(mask, clip)

    return self._finalize_mask(mask, lthr, hthr, multi, clamp, planes)

ensure_obj classmethod

ensure_obj(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self
Source code in vsmasktools/edge/_abstract.py
215
216
217
218
219
220
221
222
@classmethod
def ensure_obj(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> Self:
    return _base_ensure_obj(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

from_param classmethod

from_param(
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]
Source code in vsmasktools/edge/_abstract.py
206
207
208
209
210
211
212
213
@classmethod
def from_param(
    cls,
    edge_detect: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExceptT | None = None,
) -> type[Self]:
    return _base_from_param(cls, edge_detect, UnknownEdgeDetectError, [], func_except)

get_all_edge_detects

get_all_edge_detects(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> list[ConstantFormatVideoNode]

Returns all the EdgeDetect subclasses

Parameters:

Returns:

  • list[ConstantFormatVideoNode]

    A list of edge masks

Source code in vsmasktools/edge/_abstract.py
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
482
483
484
485
486
487
488
def get_all_edge_detects(
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> list[ConstantFormatVideoNode]:
    """
    Returns all the EdgeDetect subclasses

    Args:
        clip: Source clip
        lthr: See [EdgeDetect.get_mask][vsmasktools.edge.EdgeDetect.edgemask]
        hthr: See [EdgeDetect.get_mask][vsmasktools.edge.EdgeDetect.edgemask]
        multi: See [EdgeDetect.get_mask][vsmasktools.edge.EdgeDetect.edgemask]
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        A list of edge masks
    """
    from warnings import warn

    # https://github.com/python/mypy/issues/4717
    all_subclasses = {
        s
        for s in get_subclasses(EdgeDetect)  # type: ignore[type-abstract]
        if not isabstract(s) and s.__module__.split(".")[-1] != "_abstract"
    }

    out = list[ConstantFormatVideoNode]()

    for edge_detect in sorted(all_subclasses, key=lambda x: x.__name__):
        try:
            mask = edge_detect().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)  # pyright: ignore[reportAbstractUsage]
        except AttributeError as e:
            warn(str(e), RuntimeWarning)
            continue

        out.append(mask.text.Text(edge_detect.__name__))

    return out

get_all_ridge_detect

get_all_ridge_detect(
    clip: VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any
) -> list[ConstantFormatVideoNode]

Returns all the RidgeDetect subclasses

Parameters:

Returns:

  • list[ConstantFormatVideoNode]

    A list edge masks

Source code in vsmasktools/edge/_abstract.py
491
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
524
525
526
527
528
529
530
531
532
533
534
def get_all_ridge_detect(
    clip: vs.VideoNode,
    lthr: float = 0.0,
    hthr: float | None = None,
    multi: float = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: PlanesT = None,
    **kwargs: Any,
) -> list[ConstantFormatVideoNode]:
    """
    Returns all the RidgeDetect subclasses

    Args:
        clip: Source clip
        lthr: See [RidgeDetect.get_mask][vsmasktools.edge.RidgeDetect.ridgemask]
        hthr: See [RidgeDetect.get_mask][vsmasktools.edge.RidgeDetect.ridgemask]
        multi: See [RidgeDetect.get_mask][vsmasktools.edge.RidgeDetect.ridgemask]
        clamp: Clamp to legal values if True or specified range `(low, high)`
        planes: Which planes to process.

    Returns:
        A list edge masks
    """
    from warnings import warn

    # https://github.com/python/mypy/issues/4717
    all_subclasses = {
        s
        for s in get_subclasses(RidgeDetect)  # type: ignore[type-abstract]
        if not isabstract(s) and s.__module__.split(".")[-1] != "_abstract"
    }

    out = list[ConstantFormatVideoNode]()

    for edge_detect in sorted(all_subclasses, key=lambda x: x.__name__):
        try:
            mask = edge_detect().ridgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)  # pyright: ignore[reportAbstractUsage]
        except AttributeError as e:
            warn(str(e), RuntimeWarning)
            continue

        out.append(mask.text.Text(edge_detect.__name__))

    return out