Skip to content

edge

Masks derived from edge detectors.

Modules:

  • _1d

    1D matrices

  • _3x3

    2D matrices.

  • _5x5

    2D matrices.

  • _abstract

    This module defines core abstract classes for building edge detection and ridge detection operators.

Type Aliases:

  • EdgeDetectLike

    Type alias for anything that can resolve to a EdgeDetect.

  • RidgeDetectLike

    Type alias for anything that can resolve to a RidgeDetect.

Classes:

  • ASobel

    ASobel from the AWarpSharp2 VapourSynth plugin.

  • Cross

    "HotDoG" Operator from AVS ExTools by Dogway.

  • EdgeDetect

    Abstract base class for edge detection operators.

  • EdgeMasksEdgeDetect

    Edge detection using VapourSynth's EdgeMasks plugin with expression-based convolution fallback.

  • EuclideanDistance

    Edge detector combining two matrices via Euclidean distance.

  • 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

  • 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.

  • Kroon

    Dirk-Jan Kroon 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 flags for magnitude calculations.

  • MagnitudeEdgeMasks

    Edge detector using a subset of convolution matrices.

  • MagnitudeMatrix

    Edge detector using a subset of convolution matrices.

  • Matrix1D

    Abstract base class for one-dimensional convolution-based edge detectors.

  • Matrix3x3

    Abstract base class for 3x3 convolution-based edge detectors.

  • Matrix5x5

    Abstract base class for 5x5 convolution-based edge detectors.

  • MatrixEdgeDetect

    Edge detection based on convolution matrices.

  • Max

    Edge detector combining multiple matrices by maximum response.

  • MinMax

    Min/max mask with separate luma/chroma radii.

  • Prewitt

    Judith M. S. Prewitt operator.

  • RScharr

    Refined H. Scharr operator to more accurately calculate

  • RidgeDetect

    Edge detector specialized for ridge detection.

  • Robinson3

    Robinson compass operator level 3.

  • Robinson5

    Robinson compass operator level 5.

  • Scharr

    Original H. Scharr optimised operator which attempts

  • SingleMatrix

    Edge detector that uses a single convolution matrix.

  • Sobel

    Sobel-Feldman operator.

  • TEdge

    (TEdgeMasktype=2) Avisynth plugin.

  • TheToof

    TheToof compass operator from SharpAAMCmod.

  • Tritical

    Operator used in Tritical's original TCanny filter.

Functions:

EdgeDetectLike

EdgeDetectLike = type[EdgeDetect] | EdgeDetect | str

Type alias for anything that can resolve to a EdgeDetect.

This includes
  • A string identifier.
  • A class type subclassing EdgeDetect.
  • An instance of a EdgeDetect.

RidgeDetectLike

RidgeDetectLike = type[RidgeDetect] | RidgeDetect | str

Type alias for anything that can resolve to a RidgeDetect.

This includes
  • A string identifier.
  • A class type subclassing RidgeDetect.
  • An instance of a RidgeDetect.

ASobel

ASobel(**kwargs: Any)

Bases: Matrix3x3, EdgeDetect

ASobel from the AWarpSharp2 VapourSynth plugin.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Cross

Cross(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

EdgeDetect

EdgeDetect(**kwargs: Any)

Bases: ABC

Abstract base class for edge detection operators.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

EdgeMasksEdgeDetect

EdgeMasksEdgeDetect(**kwargs: Any)

Bases: MatrixEdgeDetect

Edge detection using VapourSynth's EdgeMasks plugin with expression-based convolution fallback.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

EuclideanDistance

EuclideanDistance(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Edge detector combining two matrices via Euclidean distance.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExKirsch

Bases: MagnitudeEdgeMasks, Max

Extended Russell Kirsch compass operator. 5x5 matrices.

Initialize the MagnitudeEdgeMasks detector.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions. If a subset is specified, the expression-based backend is used automatically to support custom directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters forwarded to the base EdgeMasksEdgeDetect class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
448
449
450
451
452
453
454
455
456
457
458
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize the MagnitudeEdgeMasks detector.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
            If a subset is specified, the expression-based backend is used automatically
            to support custom directions.
        **kwargs: Additional parameters forwarded to the base EdgeMasksEdgeDetect class.
    """
    ...

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if self.mag_directions != MagDirection.ALL:
        kwargs["use_expr"] = True

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExLaplacian1

ExLaplacian1(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ]
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExLaplacian2

ExLaplacian2(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ]
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExLaplacian3

ExLaplacian3(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ]
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExLaplacian4

ExLaplacian4(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ]
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ExPrewitt

ExPrewitt(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix5x5

Extended Judith M. S. Prewitt operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

ExSobel

ExSobel(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix5x5

Extended Sobel-Feldman operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

FDoG

FDoG(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix5x5

Flow-based Difference of Gaussian

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

Farid

Farid(**kwargs: Any)

Bases: NormalizeProcessor, RidgeDetect, EuclideanDistance, Matrix5x5

Farid & Simoncelli operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

FreyChen

FreyChen(**kwargs: Any)

Bases: NormalizeProcessor, MatrixEdgeDetect

Chen Frei operator. 3x3 matrices properly implemented.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

sqrt2 class-attribute instance-attribute

sqrt2 = sqrt(2)

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

FreyChenG41

FreyChenG41(**kwargs: Any)

Bases: RidgeDetect, EuclideanDistance, Matrix3x3

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

Kayyali

Kayyali(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Kayyali operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Kirsch

Bases: MagnitudeEdgeMasks, Max, Matrix3x3

Russell Kirsch compass operator.

Initialize the MagnitudeEdgeMasks detector.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions. If a subset is specified, the expression-based backend is used automatically to support custom directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters forwarded to the base EdgeMasksEdgeDetect class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
448
449
450
451
452
453
454
455
456
457
458
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize the MagnitudeEdgeMasks detector.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
            If a subset is specified, the expression-based backend is used automatically
            to support custom directions.
        **kwargs: Additional parameters forwarded to the base EdgeMasksEdgeDetect class.
    """
    ...

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if self.mag_directions != MagDirection.ALL:
        kwargs["use_expr"] = True

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Kroon

Kroon(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

Dirk-Jan Kroon operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

Laplacian1

Laplacian1(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 1st implementation.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Laplacian2

Laplacian2(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 2nd implementation.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Laplacian3

Laplacian3(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 3rd implementation.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Laplacian4

Laplacian4(**kwargs: Any)

Bases: SingleMatrix, Matrix3x3

Pierre-Simon de Laplace operator 4th implementation.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

LoG

LoG(**kwargs: Any)

Bases: SingleMatrix, Matrix5x5

Laplacian of Gaussian operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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,
    ]
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

MagDirection

Bases: IntFlag

Direction flags for magnitude calculations.

Includes 8 primary compass directions (N, NE, E, SE, S, SW, W, NW) and composite groups (e.g., ALL, AXIS, CORNERS). Supports bitwise operations.

Methods:

  • select_matrices

    Return matrices matching the active directions in self.

Attributes:

  • ALL

    All eight directions combined.

  • AXIS

    The four cardinal directions: North, West, South, East.

  • CORNERS

    The four intercardinal (diagonal) directions.

  • E
  • EAST

    All eastern directions (East, Northeast, Southeast).

  • N
  • NE
  • NORTH

    All northern directions (North, Northwest, Northeast).

  • NW
  • S
  • SE
  • SOUTH

    All southern directions (South, Southwest, Southeast).

  • SW
  • W
  • WEST

    All western directions (West, Northwest, Southwest).

ALL class-attribute instance-attribute

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

All eight directions combined.

AXIS class-attribute instance-attribute

AXIS = N | W | S | E

The four cardinal directions: North, West, South, East.

CORNERS class-attribute instance-attribute

CORNERS = NW | SW | SE | NE

The four intercardinal (diagonal) directions.

E class-attribute instance-attribute

E = auto()

EAST class-attribute instance-attribute

EAST = E | NE | SE

All eastern directions (East, Northeast, Southeast).

N class-attribute instance-attribute

N = auto()

NE class-attribute instance-attribute

NE = auto()

NORTH class-attribute instance-attribute

NORTH = N | NW | NE

All northern directions (North, Northwest, Northeast).

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

All southern directions (South, Southwest, Southeast).

SW class-attribute instance-attribute

SW = auto()

W class-attribute instance-attribute

W = auto()

WEST class-attribute instance-attribute

WEST = W | NW | SW

All western directions (West, Northwest, Southwest).

select_matrices

select_matrices(matrices: Sequence[T]) -> Sequence[T]

Return matrices matching the active directions in self.

Parameters:

  • matrices

    (Sequence[T]) –

    One item for each primary direction, in definition order.

Returns:

  • Sequence[T]

    The subset of matrices for directions enabled in self.

Source code in vsmasktools/edge/_abstract.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def select_matrices[T](self, matrices: Sequence[T]) -> Sequence[T]:
    """
    Return matrices matching the active directions in `self`.

    Args:
        matrices: One item for each primary direction, in definition order.

    Returns:
        The subset of matrices for directions enabled in `self`.
    """
    # 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]

MagnitudeEdgeMasks

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

Bases: EdgeMasksEdgeDetect, MagnitudeMatrix

Edge detector using a subset of convolution matrices.

Allows selecting which matrices to apply based on directional flags. By default, all directions are used.

If a subset of directions is selected, the computation automatically switches to the expression-based backend.

Initialize the MagnitudeEdgeMasks detector.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions. If a subset is specified, the expression-based backend is used automatically to support custom directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters forwarded to the base EdgeMasksEdgeDetect class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
448
449
450
451
452
453
454
455
456
457
458
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize the MagnitudeEdgeMasks detector.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
            If a subset is specified, the expression-based backend is used automatically
            to support custom directions.
        **kwargs: Additional parameters forwarded to the base EdgeMasksEdgeDetect class.
    """
    ...

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if self.mag_directions != MagDirection.ALL:
        kwargs["use_expr"] = True

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

MagnitudeMatrix

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

Bases: MatrixEdgeDetect

Edge detector using a subset of convolution matrices.

Allows selecting which matrices to apply based on directional flags. By default, all directions are used.

Initialize with a set of magnitude directions.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters passed to the base class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
421
422
423
424
425
426
427
428
429
430
431
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize with a set of magnitude directions.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
        **kwargs: Additional parameters passed to the base class.
    """
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

mag_directions instance-attribute

mag_directions = mag_directions

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Matrix1D

Matrix1D(**kwargs: Any)

Bases: EdgeDetect, ABC

Abstract base class for one-dimensional convolution-based edge detectors.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

mode_types class-attribute

mode_types: Sequence[str] | None = ['h', 'v']

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Matrix3x3

Matrix3x3(**kwargs: Any)

Bases: EdgeDetect, ABC

Abstract base class for 3x3 convolution-based edge detectors.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Matrix5x5

Matrix5x5(**kwargs: Any)

Bases: EdgeDetect, ABC

Abstract base class for 5x5 convolution-based edge detectors.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

MatrixEdgeDetect

MatrixEdgeDetect(**kwargs: Any)

Bases: EdgeDetect

Edge detection based on convolution matrices.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Max

Max(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Edge detector combining multiple matrices by maximum response.

Produces the edge mask by selecting the maximum value across all convolution results.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

MinMax

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

Bases: EdgeDetect

Min/max mask with separate luma/chroma radii.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_3x3.py
317
318
319
320
def __init__(self, rady: int = 2, radc: int = 0, **kwargs: Any) -> None:
    self.rady = rady
    self.radc = radc
    super().__init__(**kwargs)

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

radc instance-attribute

radc: int = radc

rady instance-attribute

rady: int = rady

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Prewitt

Prewitt(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

Judith M. S. Prewitt operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

RScharr

RScharr(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

RidgeDetect

RidgeDetect(**kwargs: Any)

Bases: MatrixEdgeDetect

Edge detector specialized for ridge detection.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

Robinson3

Bases: MagnitudeEdgeMasks, Max, Matrix3x3

Robinson compass operator level 3.

Initialize the MagnitudeEdgeMasks detector.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions. If a subset is specified, the expression-based backend is used automatically to support custom directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters forwarded to the base EdgeMasksEdgeDetect class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
448
449
450
451
452
453
454
455
456
457
458
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize the MagnitudeEdgeMasks detector.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
            If a subset is specified, the expression-based backend is used automatically
            to support custom directions.
        **kwargs: Additional parameters forwarded to the base EdgeMasksEdgeDetect class.
    """
    ...

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
    [],
    [],
    [],
    [],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if self.mag_directions != MagDirection.ALL:
        kwargs["use_expr"] = True

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Robinson5

Bases: MagnitudeEdgeMasks, Max, Matrix3x3

Robinson compass operator level 5.

Initialize the MagnitudeEdgeMasks detector.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions. If a subset is specified, the expression-based backend is used automatically to support custom directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters forwarded to the base EdgeMasksEdgeDetect class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
448
449
450
451
452
453
454
455
456
457
458
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize the MagnitudeEdgeMasks detector.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
            If a subset is specified, the expression-based backend is used automatically
            to support custom directions.
        **kwargs: Additional parameters forwarded to the base EdgeMasksEdgeDetect class.
    """
    ...

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
    [],
    [],
    [],
    [],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if self.mag_directions != MagDirection.ALL:
        kwargs["use_expr"] = True

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Scharr

Scharr(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

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

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

SingleMatrix

SingleMatrix(**kwargs: Any)

Bases: MatrixEdgeDetect, ABC

Edge detector that uses a single convolution matrix.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Sobel

Sobel(**kwargs: Any)

Bases: EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance, Matrix3x3

Sobel-Feldman operator.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

TEdge

TEdge(**kwargs: Any)

Bases: Matrix1D, EuclideanDistance

(TEdgeMasktype=2) Avisynth plugin.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

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

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

matrices: Sequence[Sequence[float]] = [
    [12, -74, 0, 74, -12],
    [-12, 74, 0, -74, 12],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = ['h', 'v']

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

TheToof

Bases: MagnitudeMatrix, Max, Matrix3x3

TheToof compass operator from SharpAAMCmod.

Initialize with a set of magnitude directions.

Parameters:

  • mag_directions

    (MagDirection, default: ALL ) –

    Directional flags controlling which matrices are used. Defaults to all directions.

  • **kwargs

    (Any, default: {} ) –

    Additional parameters passed to the base class.

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

Attributes:

Source code in vsmasktools/edge/_abstract.py
421
422
423
424
425
426
427
428
429
430
431
def __init__(self, mag_directions: MagDirection = MagDirection.ALL, **kwargs: Any) -> None:
    """
    Initialize with a set of magnitude directions.

    Args:
        mag_directions: Directional flags controlling which matrices are used. Defaults to all directions.
        **kwargs: Additional parameters passed to the base class.
    """
    super().__init__(**kwargs)

    self.mag_directions = mag_directions

divisors class-attribute

divisors: Sequence[float] | None = [4] * 4

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

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],
    [],
    [],
    [],
    [],
]

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = None

Optional convolution modes (e.g. 's' for square). Defaults to 's'.

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    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
    """
    clip_p = self._preprocess(clip, **kwargs)

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

    mask = self._postprocess(mask, clip)

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

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

Tritical

Tritical(**kwargs: Any)

Bases: Matrix1D, EdgeMasksEdgeDetect, RidgeDetect, EuclideanDistance

Operator used in Tritical's original TCanny filter. Plain and simple orthogonal first order derivative.

Initialize the scaler with optional keyword arguments.

Parameters:

  • **kwargs

    (Any, default: {} ) –

    Keyword arguments passed to the edgemask function(s).

Methods:

  • edgemask

    Makes edge mask based on convolution kernel.

  • ensure_obj

    Ensure that the input is an edgemask instance, resolving it if necessary.

  • from_param

    Resolve and return an edgemask type from a given input (string, type, or instance).

  • ridgemask

    Makes ridge mask based on convolution kernel.

Attributes:

Source code in vsmasktools/edge/_abstract.py
156
157
158
159
160
161
162
163
def __init__(self, **kwargs: Any) -> None:
    """
    Initialize the scaler with optional keyword arguments.

    Args:
        **kwargs: Keyword arguments passed to the edgemask function(s).
    """
    self.kwargs = kwargs

divisors class-attribute

divisors: Sequence[float] | None = None

Optional divisors applied to each kernel. Defaults to zeros (no division).

kwargs instance-attribute

kwargs: dict[str, Any] = kwargs

Arguments passed to the edgemask function(s).

matrices class-attribute

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

Convolution kernels used for edge detection.

mode_types class-attribute

mode_types: Sequence[str] | None = ['h', 'v']

edgemask

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

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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@inject_self
@inject_kwargs_params
def edgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = None,
    **kwargs: Any,
) -> vs.VideoNode:
    if not hasattr(core, "edgemasks"):
        kwargs.setdefault("use_expr", True)

    return super().edgemask(clip, lthr, hthr, multi, clamp, planes, **kwargs)

ensure_obj classmethod

ensure_obj(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> Self

Ensure that the input is an edgemask instance, resolving it if necessary.

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • Self

    Edgemask instance.

Source code in vsmasktools/edge/_abstract.py
225
226
227
228
229
230
231
232
233
234
235
236
237
@classmethod
def ensure_obj(cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None) -> Self:
    """
    Ensure that the input is an edgemask instance, resolving it if necessary.

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Edgemask instance.
    """
    return _base_ensure_obj(cls, value, func_except)

from_param classmethod

from_param(
    value: type[Self] | Self | str | None = None,
    /,
    func_except: FuncExcept | None = None,
) -> type[Self]

Resolve and return an edgemask type from a given input (string, type, or instance).

Parameters:

  • value

    (type[Self] | Self | str | None, default: None ) –

    Edgemask identifier (string, class, or instance).

  • func_except

    (FuncExcept | None, default: None ) –

    Function returned for custom error handling.

Returns:

  • type[Self]

    Resolved edgemask type.

Source code in vsmasktools/edge/_abstract.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@classmethod
def from_param(
    cls, value: type[Self] | Self | str | None = None, /, func_except: FuncExcept | None = None
) -> type[Self]:
    """
    Resolve and return an edgemask type from a given input (string, type, or instance).

    Args:
        value: Edgemask identifier (string, class, or instance).
        func_except: Function returned for custom error handling.

    Returns:
        Resolved edgemask type.
    """
    return _base_from_param(cls, value, cls._err_class, func_except)

ridgemask

ridgemask(
    clip: VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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 | Sequence[float] | None, default: None ) –

    Low threshold. Anything below lthr will be set to 0

  • hthr

    (float | Sequence[float] | None, default: None ) –

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

  • multi

    (float | Sequence[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

    (Planes, default: None ) –

    Which planes to process.

Returns:

  • VideoNode

    Mask clip

Source code in vsmasktools/edge/_abstract.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
@inject_self
@inject_kwargs_params
def ridgemask(
    self,
    clip: vs.VideoNode,
    lthr: float | Sequence[float] | None = None,
    hthr: float | Sequence[float] | None = None,
    multi: float | Sequence[float] = 1.0,
    clamp: bool | tuple[float, float] | list[tuple[float, float]] = False,
    planes: Planes = 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
    """
    clip_p = self._preprocess_ridge(clip)

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

    mask = self._postprocess_ridge(mask, clip)

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

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: Planes = None,
    **kwargs: Any
) -> list[VideoNode]

Returns all the EdgeDetect subclasses

Parameters:

Returns:

  • list[VideoNode]

    A list of edge masks

Source code in vsmasktools/edge/_abstract.py
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
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: Planes = None,
    **kwargs: Any,
) -> list[vs.VideoNode]:
    """
    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
    """
    # 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[vs.VideoNode]()

    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:
            from warnings import warn

            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: Planes = None,
    **kwargs: Any
) -> list[VideoNode]

Returns all the RidgeDetect subclasses

Parameters:

Returns:

  • list[VideoNode]

    A list edge masks

Source code in vsmasktools/edge/_abstract.py
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
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: Planes = None,
    **kwargs: Any,
) -> list[vs.VideoNode]:
    """
    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
    """
    # 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[vs.VideoNode]()

    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:
            from warnings import warn

            warn(str(e), RuntimeWarning)
            continue

        out.append(mask.text.Text(edge_detect.__name__))

    return out