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 ae51317 commit a2af1f6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion vsrgtools/contra.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def contrasharpening_dehalo(

rep_modes = norm_rmode_planes(flt, RepairMode.MINMAX_SQUARE1, planes)

weighted = BlurMatrix.WMEAN()(flt, planes)
weighted = BlurMatrix.BINOMIAL()(flt, planes)
weighted2 = median_blur(weighted, 2, planes=planes)
weighted2 = iterate(weighted2, partial(repair, repairclip=weighted), 2, mode=rep_modes)

Expand Down
16 changes: 2 additions & 14 deletions vsrgtools/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ def outer(self) -> Self:
class BlurMatrix(CustomIntEnum):
CIRCLE = 0
MEAN = 1
WMEAN = 2
BINOMIAL = 3
LOG = 4
BINOMIAL = 2
LOG = 3

@to_singleton.as_property
class GAUSS:
Expand Down Expand Up @@ -229,12 +228,6 @@ def __call__( # type: ignore[misc]
) -> BlurMatrixBase[int]:
...

@overload
def __call__( # type: ignore[misc]
self: Literal[BlurMatrix.WMEAN], taps: int = 1, *, mode: ConvMode = ConvMode.SQUARE
) -> BlurMatrixBase[int]:
...

@overload
def __call__( # type: ignore[misc]
self: Literal[BlurMatrix.LOG], taps: int = 1, *, strength: float = 100.0, mode: ConvMode = ConvMode.HV
Expand Down Expand Up @@ -272,11 +265,6 @@ def __call__(self, taps: int = 1, **kwargs: Any) -> Any:

kernel = BlurMatrixBase(matrix[:-1] + matrix[::-1], mode)

case BlurMatrix.WMEAN:
mode = kwargs.pop("mode", ConvMode.SQUARE)

return BlurMatrix.BINOMIAL(taps, mode=mode, **kwargs)

case BlurMatrix.LOG:
mode = kwargs.pop("mode", ConvMode.HV)
strength = kwargs.get("strength", 100)
Expand Down
2 changes: 1 addition & 1 deletion vsrgtools/rgtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def removegrain(clip: vs.VideoNode, mode: RemoveGrainModeT) -> vs.VideoNode:
for idx, m in enumerate(mode):
if m == RemoveGrainMode.SQUARE_BLUR:
if all(mm == m for mm in mode):
return BlurMatrix.WMEAN()(clip)
return BlurMatrix.BINOMIAL()(clip)
expr.append(aka_removegrain_expr_11_12())
elif RemoveGrainMode.BOB_TOP_CLOSE <= m <= RemoveGrainMode.BOB_BOTTOM_INTER:
return pick_func_stype(clip, clip.rgvs.RemoveGrain, clip.rgsf.RemoveGrain)(mode)
Expand Down
2 changes: 1 addition & 1 deletion vsrgtools/sharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def limit_usm(
elif blur <= 0:
blurred = min_blur(clip, -blur, planes)
elif blur == 1:
blurred = BlurMatrix.WMEAN()(clip, planes)
blurred = BlurMatrix.BINOMIAL()(clip, planes)
elif blur == 2:
blurred = BlurMatrix.MEAN()(clip, planes)
else:
Expand Down
2 changes: 1 addition & 1 deletion vsrgtools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'normalize_radius'
]

wmean_matrix = list(BlurMatrix.WMEAN(1, mode=ConvMode.SQUARE))
wmean_matrix = list(BlurMatrix.BINOMIAL(1, mode=ConvMode.SQUARE))
mean_matrix = list(BlurMatrix.MEAN(1, mode=ConvMode.SQUARE))

RModeT = TypeVar('RModeT', RemoveGrainMode, RepairMode)
Expand Down

0 comments on commit a2af1f6

Please sign in to comment.