Skip to content

Commit

Permalink
Merge files
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Aug 4, 2024
1 parent 74eb340 commit 8405138
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 138 deletions.
2 changes: 0 additions & 2 deletions vskernels/kernels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from .bicubic import * # noqa: F401, F403
from .complex import * # noqa: F401, F403
from .custom import * # noqa: F401, F403
from .ewa import * # noqa: F401, F403
from .placebo import * # noqa: F401, F403
from .resize import * # noqa: F401, F403
from .spline import * # noqa: F401, F403
from .various import * # noqa: F401, F403
79 changes: 0 additions & 79 deletions vskernels/kernels/ewa.py

This file was deleted.

73 changes: 72 additions & 1 deletion vskernels/kernels/placebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
from .complex import LinearScaler

__all__ = [
'Placebo'
'Placebo',
'EwaBicubic',
'EwaJinc',
'EwaLanczos',
'EwaGinseng',
'EwaHann',
'EwaHannSoft',
'EwaRobidoux',
'EwaRobidouxSharp',
]


Expand Down Expand Up @@ -90,3 +98,66 @@ def kernel_radius(self) -> int: # type: ignore
return Bicubic(fallback(self.b, 0), fallback(self.c, 0.5)).kernel_radius

return 2


class EwaBicubic(Placebo):
_kernel = 'ewa_robidoux'

def __init__(self, b: float = 0.0, c: float = 0.5, radius: int | None = None, **kwargs: Any) -> None:
radius = kwargs.pop('taps', radius)

if radius is None:
from .bicubic import Bicubic

radius = Bicubic(b, c).kernel_radius

super().__init__(radius, b, c, **kwargs)


class EwaLanczos(Placebo):
_kernel = 'ewa_lanczos'

def __init__(self, taps: float = 3.2383154841662362076499, **kwargs: Any) -> None:
super().__init__(taps, None, None, **kwargs)


class EwaJinc(Placebo):
_kernel = 'ewa_jinc'

def __init__(self, taps: float = 3.2383154841662362076499, **kwargs: Any) -> None:
super().__init__(taps, None, None, **kwargs)


class EwaGinseng(Placebo):
_kernel = 'ewa_ginseng'

def __init__(self, taps: float = 3.2383154841662362076499, **kwargs: Any) -> None:
super().__init__(taps, None, None, **kwargs)


class EwaHann(Placebo):
_kernel = 'ewa_hann'

def __init__(self, taps: float = 3.2383154841662362076499, **kwargs: Any) -> None:
super().__init__(taps, None, None, **kwargs)


class EwaHannSoft(Placebo):
_kernel = 'haasnsoft'

def __init__(self, taps: float = 3.2383154841662362076499, **kwargs: Any) -> None:
super().__init__(taps, None, None, **kwargs)


class EwaRobidoux(Placebo):
_kernel = 'ewa_robidoux'

def __init__(self, **kwargs: Any) -> None:
super().__init__(None, None, None, **kwargs)


class EwaRobidouxSharp(Placebo):
_kernel = 'ewa_robidouxsharp'

def __init__(self, **kwargs: Any) -> None:
super().__init__(None, None, None, **kwargs)
51 changes: 0 additions & 51 deletions vskernels/kernels/resize.py

This file was deleted.

46 changes: 41 additions & 5 deletions vskernels/kernels/various.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from .helpers import sinc

__all__ = [
'Point',
'Bilinear',
'Lanczos',
'Gaussian',
'Box',
'BlackMan',
Expand Down Expand Up @@ -44,15 +47,48 @@ def to_libplacebo(self, sigma: float) -> float:
return 4 * (sigma ** 2)


class Point(CustomComplexKernel):
"""Point resizer."""

_static_kernel_radius = 1

@inject_self
def kernel(self, *, x: float) -> float: # type: ignore
return 1.0


class Bilinear(CustomComplexKernel):
"""Bilinear resizer."""

_static_kernel_radius = 1

@inject_self
def kernel(self, *, x: float) -> float: # type: ignore
return max(1.0 - abs(x), 0.0)


class Lanczos(CustomComplexTapsKernel):
"""
Lanczos resizer.
:param taps: taps param for lanczos kernel
"""

def __init__(self, taps: int = 3, **kwargs: Any) -> None:
super().__init__(taps, **kwargs)

@inject_self
def kernel(self, *, x: float) -> float: # type: ignore
x, taps = abs(x), self.kernel_radius

return sinc(x) * sinc(x / taps) if x < taps else 0.0


class Gaussian(CustomComplexTapsKernel):
"""Gaussian resizer."""

def __init__(self, sigma: float = 0.5, taps: int = 2, **kwargs: Any) -> None:
"""
Sigma is imagemagick's sigma scaling.
You can specify "curve" to override sigma and specify the original `a1` value.
"""
"""Sigma is the same as imagemagick's sigma scaling."""

self._sigma = sigma

Expand Down

0 comments on commit 8405138

Please sign in to comment.