Skip to content

Commit

Permalink
Switch to scale_mask/scale_delta
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Nov 15, 2024
1 parent cef1693 commit d67eea8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions vsmasktools/edge/_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vstools import (
ColorRange, CustomRuntimeError, CustomValueError, FuncExceptT, KwargsT, PlanesT, T, check_variable, core,
get_lowest_values, get_peak_value, get_peak_values, get_subclasses, inject_self, join, normalize_planes, plane,
scale_value, vs
scale_mask, vs
)

from ..exceptions import UnknownEdgeDetectError, UnknownRidgeDetectError
Expand Down Expand Up @@ -183,8 +183,8 @@ def _mask(
peak = get_peak_value(clip)
hthr = 1.0 if hthr is None else hthr

lthr = scale_value(lthr, 32, clip, range_out=ColorRange.FULL)
hthr = scale_value(hthr, 32, clip, range_out=ColorRange.FULL)
lthr = scale_mask(lthr, 32, clip)
hthr = scale_mask(hthr, 32, clip)

discard_planes = False
if isinstance(planes, tuple):
Expand Down
6 changes: 3 additions & 3 deletions vsmasktools/edge_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from vsrgtools.util import wmean_matrix
from vstools import (
ColorRange, CustomEnum, VSFunctionAllArgs, check_variable, core, depth, get_peak_value, get_y, iterate, plane,
scale_value, vs
scale_value, scale_mask, vs
)

from .details import multi_detail_mask
Expand Down Expand Up @@ -41,7 +41,7 @@ def ringing_mask(
assert check_variable(clip, ringing_mask)

thmi, thma, thlimi, thlima = (
scale_value(t, 32, clip, range_out=ColorRange.FULL) for t in [thmi, thma, thlimi, thlima]
scale_mask(t, 32, clip) for t in [thmi, thma, thlimi, thlima]
)

edgemask = normalize_mask(credit_mask, plane(clip, 0), **kwargs).std.Limiter()
Expand Down Expand Up @@ -83,7 +83,7 @@ def luma_credit_mask(

edge_mask = normalize_mask(edgemask, y, **kwargs)

credit_mask = norm_expr([edge_mask, y], f'y {scale_value(thr, 32, y, range_out=ColorRange.FULL)} > y 0 ? x min')
credit_mask = norm_expr([edge_mask, y], f'y {scale_mask(thr, 32, y)} > y 0 ? x min')

if not draft:
credit_mask = Morpho.maximum(credit_mask, iterations=4)
Expand Down
6 changes: 3 additions & 3 deletions vsmasktools/hardsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ColorRange, CustomOverflowError, FileNotExistsError, FilePathType, FrameRangeN, FrameRangesN,
Matrix, VSFunction, check_variable, core, depth, fallback, get_lowest_value, get_neutral_value,
get_neutral_values, get_peak_value, get_y, iterate, normalize_ranges, replace_ranges,
scale_value, vs, vs_object
scale_value, scale_delta, vs, vs_object
)

from .abstract import DeferredMask, GeneralMask
Expand Down Expand Up @@ -131,7 +131,7 @@ def get_progressive_dehardsub(

assert masks[-1].format is not None

thr = scale_value(self.bin_thr, 32, masks[-1], range_out=ColorRange.FULL)
thr = scale_value(self.bin_thr, 32, masks[-1])

for p in partials:
masks.append(
Expand Down Expand Up @@ -180,7 +180,7 @@ def _mask(self, clip: vs.VideoNode, ref: vs.VideoNode, **kwargs: Any) -> vs.Vide
for x in (clip, ref)
)

highpass = scale_value(self.highpass, 32, clip)
highpass = scale_delta(self.highpass, 32, clip)

mask = norm_expr(
[clipedge, refedge], f'x y - {highpass} < 0 {ExprToken.RangeMax} ?'
Expand Down

0 comments on commit d67eea8

Please sign in to comment.