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 14, 2024
1 parent 9cbfdf5 commit 231a9ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions vsdehalo/alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
)
from vsrgtools.util import norm_rmode_planes
from vstools import (
ColorRange, ConvMode, CustomIndexError, CustomIntEnum, CustomValueError, FieldBased, FuncExceptT, FunctionUtil,
ConvMode, CustomIndexError, CustomIntEnum, CustomValueError, FieldBased, FuncExceptT, FunctionUtil,
InvalidColorFamilyError, KwargsT, PlanesT, UnsupportedFieldBasedError, check_ref_clip, check_variable, clamp,
cround, fallback, get_peak_value, get_y, join, mod4, normalize_planes, normalize_seq, scale_value, split, to_arr,
cround, fallback, get_peak_value, get_y, join, mod4, normalize_planes, normalize_seq, scale_mask, split, to_arr,
vs
)

Expand Down Expand Up @@ -202,7 +202,7 @@ def __call__(
raise CustomValueError('valid values for show_mask are 1–7!', func)

thmif, thmaf, thlimif, thlimaf = [
scale_value(x, 8, clip, ColorRange.FULL, ColorRange.FULL)
scale_mask(x, 8, clip)
for x in [thmi, thma, thlimi, thlima]
]

Expand Down Expand Up @@ -704,7 +704,7 @@ def dehalomicron(

if brz:
dmask_expr = (
f"x {scale_value(abs(brz), 32, y, ColorRange.FULL, ColorRange.FULL)} "
f"x {scale_mask(abs(brz), 32, y)} "
f"{'>' if brz < 0.0 else '>'} 0 x 2 * ?"
)
else:
Expand Down
4 changes: 2 additions & 2 deletions vsdehalo/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from vskernels import Point
from vsmasktools import Morpho, PrewittTCanny
from vsrgtools import BlurMatrix
from vstools import ColorRange, FieldBased, UnsupportedFieldBasedError, get_y, scale_value, vs
from vstools import FieldBased, UnsupportedFieldBasedError, get_y, scale_delta, vs


__all__ = [
Expand Down Expand Up @@ -43,7 +43,7 @@ def base_dehalo_mask(

exp_edges = norm_expr(
[luma, Morpho.maximum(luma, iterations=2)], 'y x - {shift} - range_half *',
shift=scale_value(shift, 8, luma, ColorRange.FULL, ColorRange.FULL)
shift=scale_delta(shift, 8, luma)
)

edgemask = PrewittTCanny.edgemask(exp_edges, sigma=sqrt(expand * 2), mode=-1, multi=16)
Expand Down
14 changes: 7 additions & 7 deletions vsdehalo/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from vsrgtools.util import mean_matrix, wmean_matrix
from vstools import (
ColorRange, DitherType, PlanesT, core, cround, disallow_variable_format, disallow_variable_resolution, depth_func,
get_peak_value, get_y, join, normalize_planes, padder, scale_value, split, vs
get_peak_value, get_y, join, normalize_planes, padder, scale_mask, split, vs
)

__all__ = [
Expand Down Expand Up @@ -63,8 +63,8 @@ def edge_cleaner(
y_mask = get_y(work_clip)

mask = edgemask.edgemask(y_mask).std.Expr(
f'x {scale_value(4, 8, work_clip, ColorRange.FULL, ColorRange.FULL)} < 0 x '
f'{scale_value(32, 8, work_clip, ColorRange.FULL, ColorRange.FULL)} > {peak} x ? ?'
f'x {scale_mask(4, 8, work_clip)} < 0 x '
f'{scale_mask(32, 8, work_clip)} > {peak} x ? ?'
).std.InvertMask()
mask = mask.std.Convolution(mean_matrix)

Expand All @@ -80,13 +80,13 @@ def edge_cleaner(

mask = edgemask.edgemask(
diff.std.Levels(
scale_value(40, 8, work_clip, ColorRange.FULL, ColorRange.FULL),
scale_value(168, 8, work_clip, ColorRange.FULL, ColorRange.FULL),
scale_mask(40, 8, work_clip),
scale_mask(168, 8, work_clip),
0.35
)
)
sc4 = scale_value(4, 8, work_clip, ColorRange.FULL, ColorRange.FULL)
sc16 = scale_value(16, 8, work_clip, ColorRange.FULL, ColorRange.FULL)
sc4 = scale_mask(4, 8, work_clip)
sc16 = scale_mask(16, 8, work_clip)
mask = removegrain(mask, 7).std.Expr(f'x {sc4} < 0 x {sc16} > {peak} x ? ?')

final = final.std.MaskedMerge(work_clip, mask)
Expand Down

0 comments on commit 231a9ad

Please sign in to comment.