Skip to content

Commit

Permalink
Update value scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Oct 14, 2024
1 parent 68152af commit 9cbfdf5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions vsdehalo/alpha.py
Original file line number Diff line number Diff line change
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)
scale_value(x, 8, clip, ColorRange.FULL, ColorRange.FULL)
for x in [thmi, thma, thlimi, thlima]
]

Expand Down Expand Up @@ -703,7 +703,10 @@ def dehalomicron(
dehalo_mask = RemoveGrainMode.MINMAX_MEDIAN_OPP(dehalo_mask)

if brz:
dmask_expr = f"x {scale_value(abs(brz), 32, y, ColorRange.FULL)} {'>' if brz < 0.0 else '>'} 0 x 2 * ?"
dmask_expr = (
f"x {scale_value(abs(brz), 32, y, ColorRange.FULL, ColorRange.FULL)} "
f"{'>' if brz < 0.0 else '>'} 0 x 2 * ?"
)
else:
dmask_expr = 'x 2 *'

Expand Down
2 changes: 1 addition & 1 deletion vsdehalo/mask.py
Original file line number Diff line number Diff line change
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)
shift=scale_value(shift, 8, luma, ColorRange.FULL, ColorRange.FULL)
)

edgemask = PrewittTCanny.edgemask(exp_edges, sigma=sqrt(expand * 2), mode=-1, multi=16)
Expand Down
12 changes: 6 additions & 6 deletions vsdehalo/warp.py
Original file line number Diff line number Diff line change
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)} < 0 x '
f'{scale_value(32, 8, work_clip, ColorRange.FULL)} > {peak} x ? ?'
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 ? ?'
).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),
scale_value(168, 8, work_clip, ColorRange.FULL),
scale_value(40, 8, work_clip, ColorRange.FULL, ColorRange.FULL),
scale_value(168, 8, work_clip, ColorRange.FULL, ColorRange.FULL),
0.35
)
)
sc4 = scale_value(4, 8, work_clip, ColorRange.FULL)
sc16 = scale_value(16, 8, work_clip, ColorRange.FULL)
sc4 = scale_value(4, 8, work_clip, ColorRange.FULL, ColorRange.FULL)
sc16 = scale_value(16, 8, work_clip, ColorRange.FULL, ColorRange.FULL)
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 9cbfdf5

Please sign in to comment.