diff --git a/vsmasktools/edge_funcs.py b/vsmasktools/edge_funcs.py index 7504fb0..707d13d 100644 --- a/vsmasktools/edge_funcs.py +++ b/vsmasktools/edge_funcs.py @@ -67,8 +67,8 @@ def luma_mask(clip: vs.VideoNode, thr_lo: float, thr_hi: float, invert: bool = T lo, hi = (peak, 0) if invert else (0, peak) inv_pre, inv_post = (peak, '-') if invert else ('', '') - thr_lo = scale_value(thr_lo, 32, clip, range_out=ColorRange.FULL) - thr_hi = scale_value(thr_hi, 32, clip, range_out=ColorRange.FULL) + thr_lo = scale_value(thr_lo, 32, clip) + thr_hi = scale_value(thr_hi, 32, clip) return norm_expr( get_y(clip), @@ -135,7 +135,7 @@ def _prefilter(self, clip: vs.VideoNode, **kwargs: Any) -> vs.VideoNode: if self is self.CLAHE: # type: ignore limit, tile = kwargs.get('limit', 0.0305), kwargs.get('tile', 5) - return depth(depth(clip, 16).ehist.CLAHE(scale_value(limit, 32, 16, range_out=ColorRange.FULL), tile), clip) + return depth(depth(clip, 16).ehist.CLAHE(scale_value(limit, 32, 16), tile), clip) return clip diff --git a/vsmasktools/hardsub.py b/vsmasktools/hardsub.py index 80aac8d..e4f9a4f 100644 --- a/vsmasktools/hardsub.py +++ b/vsmasktools/hardsub.py @@ -179,7 +179,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, range_out=ColorRange.FULL) + highpass = scale_value(self.highpass, 32, clip) mask = norm_expr( [clipedge, refedge], f'x y - {highpass} < 0 {ExprToken.RangeMax} ?' diff --git a/vsmasktools/morpho.py b/vsmasktools/morpho.py index 7758b07..d4050ff 100644 --- a/vsmasktools/morpho.py +++ b/vsmasktools/morpho.py @@ -9,7 +9,7 @@ from vsrgtools.util import wmean_matrix from vstools import ( ConvMode, CustomIndexError, FuncExceptT, PlanesT, StrList, check_variable, copy_signature, core, fallback, - ColorRange, inject_self, interleave_arr, iterate, scale_value, to_arr, vs + inject_self, interleave_arr, iterate, scale_value, to_arr, vs ) from .types import Coordinates, MorphoFunc, XxpandMode @@ -112,7 +112,7 @@ def _morpho_xx_imum( matrix = ExprList(interleave_arr(matrix, op * matrix.mlength, 2)) if thr is not None: - matrix.append('x', scale_value(thr, 32, src, range_out=ColorRange.FULL), ExprOp.SUB, ExprOp.MAX) + matrix.append('x', scale_value(thr, 32, src), ExprOp.SUB, ExprOp.MAX) if multiply is not None: matrix.append(multiply, ExprOp.MUL) @@ -150,7 +150,7 @@ def _mm_func( if not self._fast: if thr is not None: - kwargs.update(threshold=scale_value(thr, 32, src, range_out=ColorRange.FULL)) + kwargs.update(threshold=scale_value(thr, 32, src)) if multiply is not None: orig_mm_func = mm_func @@ -211,7 +211,7 @@ def _xxflate( expr.append('x', ExprOp.MAX if inflate else ExprOp.MIN) if thr is not None: - thr = scale_value(thr, 32, src, range_out=ColorRange.FULL) + thr = scale_value(thr, 32, src) limit = ['x', thr, ExprOp.ADD] if inflate else ['x', thr, ExprOp.SUB, ExprToken.RangeMin, ExprOp.MAX] expr.append(limit, ExprOp.MIN if inflate else ExprOp.MAX) @@ -315,21 +315,21 @@ def gradient( eroded = self.erosion(src, radius, planes, thr, coords, multiply, func=func, **kwargs) dilated = self.dilation(src, radius, planes, thr, coords, multiply, func=func, **kwargs) - return norm_expr([dilated, eroded], 'x y -', planes) + return core.std.MakeDiff(dilated, eroded, planes) @inject_self @copy_signature(_morpho_method) def top_hat(self, src: vs.VideoNode, *args: Any, func: FuncExceptT | None = None, **kwargs: Any) -> vs.VideoNode: opened = self.opening(src, *args, func=func or self.top_hat, **kwargs) - return norm_expr([src, opened], 'x y -', kwargs.get('planes', args[1] if len(args) > 1 else None)) + return core.std.MakeDiff(src, opened, kwargs.get('planes', args[1] if len(args) > 1 else None)) @inject_self @copy_signature(_morpho_method) def black_hat(self, src: vs.VideoNode, *args: Any, func: FuncExceptT | None = None, **kwargs: Any) -> vs.VideoNode: closed = self.closing(src, *args, func=func or self.black_hat, **kwargs) - return norm_expr([closed, src], 'x y -', kwargs.get('planes', args[1] if len(args) > 1 else None)) + return core.std.MakeDiff(closed, src, kwargs.get('planes', args[1] if len(args) > 1 else None)) @inject_self def outer_hat( @@ -347,7 +347,7 @@ def outer_hat( dilated = self.dilation(src, radius, planes, thr, coords, multiply, func=func, **kwargs) - return norm_expr([dilated, src], 'x y -', planes) + return core.std.MakeDiff(dilated, src, planes) @inject_self def inner_hat( @@ -365,7 +365,7 @@ def inner_hat( eroded = self.erosion(src, radius, planes, thr, coords, multiply, func=func, **kwargs) - return norm_expr([eroded, src], 'x y -', planes) + return core.std.MakeDiff(src, eroded, planes) @inject_self def binarize( @@ -375,7 +375,7 @@ def binarize( ) -> vs.VideoNode: midthr, lowval, highval = ( thr and list( - scale_value(t, 32, src, range_out=ColorRange.FULL) + scale_value(t, 32, src) for i, t in enumerate(to_arr(thr)) ) for thr in (midthr, lowval, highval) ) diff --git a/vsmasktools/spat_funcs.py b/vsmasktools/spat_funcs.py index e1c00e9..1462012 100644 --- a/vsmasktools/spat_funcs.py +++ b/vsmasktools/spat_funcs.py @@ -149,7 +149,7 @@ def flat_mask(src: vs.VideoNode, radius: int = 5, thr: float = 0.011, gauss: boo blur = gauss_blur(luma, radius * 0.361083333) if gauss else box_blur(luma, radius) - mask = depth(luma, 8).abrz.AdaptiveBinarize(depth(blur, 8), scale_value(thr, 32, 8, range_out=ColorRange.FULL)) + mask = depth(luma, 8).abrz.AdaptiveBinarize(depth(blur, 8), scale_value(thr, 32, 8)) return depth(mask, luma, dither_type=DitherType.NONE, range_in=ColorRange.FULL, range_out=ColorRange.FULL) @@ -161,8 +161,8 @@ def texture_mask( points: list[tuple[bool, float]] = [(False, 1.75), (True, 2.5), (True, 5), (False, 10)] ) -> vs.VideoNode: levels = [x for x, _ in points] - _points = [scale_value(x, 8, clip, ColorRange.FULL, ColorRange.FULL) for _, x in points] - thr = scale_value(thr, 8, 32, ColorRange.FULL, ColorRange.FULL) + _points = [scale_value(x, 8, clip) for _, x in points] + thr = scale_value(thr, 8, 32, ColorRange.FULL) qm, peak = len(points), get_peak_value(clip)