Skip to content

Commit

Permalink
Move away from wmean_matrix/mean_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Jan 7, 2025
1 parent 76f0548 commit b7e95b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vsdehalo/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def base_dehalo_mask(
halo_mask = Morpho.inflate(halo_mask, iterations=2)
halo_mask = Morpho.binarize(halo_mask, brz1)

mask = norm_expr([edgemask, BlurMatrix.WMEAN(halo_mask)], 'x y min {multi} *', multi=multi)
mask = norm_expr([edgemask, BlurMatrix.BINOMIAL()(halo_mask)], 'x y min {multi} *', multi=multi)

if pre_ss:
return Point.scale(mask, src.width, src.height)
Expand Down
9 changes: 4 additions & 5 deletions vsdehalo/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from typing import Sequence

from vsmasktools import EdgeDetect, EdgeDetectT, PrewittStd
from vsrgtools import min_blur, removegrain, repair
from vsrgtools.util import mean_matrix, wmean_matrix
from vsrgtools import min_blur, removegrain, repair, BlurMatrix, box_blur
from vstools import (
DitherType, PlanesT, core, cround, disallow_variable_format, disallow_variable_resolution, depth_func,
get_peak_value, get_y, join, normalize_planes, padder, scale_mask, split, vs
Expand Down Expand Up @@ -66,7 +65,7 @@ def edge_cleaner(
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)
mask = box_blur(mask)

final = work_clip.std.MaskedMerge(warped, mask)

Expand Down Expand Up @@ -131,7 +130,7 @@ def YAHR(

blur_diff, blur_warped_diff = [
c.std.MakeDiff(
min_blur(c, 2, planes).std.Convolution(wmean_matrix, planes=planes), planes
BlurMatrix.BINOMIAL()(min_blur(c, 2, planes), planes=planes), planes
) for c in (work_clip, warped)
]

Expand All @@ -150,7 +149,7 @@ def YAHR(

mask1 = vEdge.tcanny.TCanny(sqrt(expand * 2), mode=-1)

mask2 = vEdge.std.Convolution(wmean_matrix).std.Invert()
mask2 = BlurMatrix.BINOMIAL()(vEdge, planes=planes).std.Invert()

mask = core.std.Expr([mask1, mask2], 'x 16 * y min 0 max 1 min' if is_float else 'x 16 * y min')

Expand Down

0 comments on commit b7e95b6

Please sign in to comment.