Selur
18th March 2020, 19:18
Hi,
G41Fun.py (no clue what happened to the original github for this) contained a psharpen port:
def psharpen(clip, strength=25, threshold=75, ssx=1, ssy=1, dw=None, dh=None):
"""
From https://forum.doom9.org/showthread.php?p=683344 by ilpippo80.
Sharpeing function similar to LimitedSharpenFaster,
performs two-point sharpening to avoid overshoot.
Args:
strength (float) - Strength of the sharpening, 0 to 100.
threshold (float) - Controls "how much" to be sharpened, 0 to 100.
ssx, ssy (float) - Supersampling factor (reduce aliasing on edges).
dw, dh (int) - Output resolution after sharpening.
"""
if not isinstance(clip, vs.VideoNode):
raise TypeError("psharpen: This is not a clip!")
if clip.format.sample_type != vs.INTEGER:
raise TypeError("psharpen: clip must be of integer sample type")
if clip.format.color_family == vs.COMPAT:
raise TypeError("psharpen: COMPAT color family is not supported!")
color = clip.format.color_family
ow = clip.width
oh = clip.height
ssx = max(ssx, 1.0)
ssy = max(ssy, 1.0)
strength = min(max(strength, 0), 100)
threshold = min(max(threshold, 0), 100)
xss = m4(ow * ssx)
yss = m4(oh * ssy)
if dw is None:
dw = ow
if dh is None:
dh = oh
# oversampling
if ssx > 1 or ssy > 1:
clip = core.resize.Spline36(clip, xss, yss)
tmp = core.std.ShufflePlanes(clip, [0], vs.GRAY) if color in [vs.YUV, vs.YCOCG] else clip
# calculating the max and min in every 3*3 square
maxi = core.std.Maximum(tmp)
mini = core.std.Minimum(tmp)
# normalizing max and val to values from 0 to (max-min)
nmax = core.std.Expr([maxi, mini], ['x y -'])
nval = core.std.Expr([tmp, mini], ['x y -'])
# initializing expression used to obtain the output luma value
s = strength / 100
t = threshold / 100
st = 1 - (s / (s + t - s * t))
expr = 'x y / 2 * 1 - abs {} < {} 1 = x y 2 / = 0 y 2 / ? x y / 2 * 1 - abs 1 {} - / ? x y / 2 * 1 - abs 1 {} - * {} + ? x y 2 / > 1 -1 ? * 1 + y * 2 /'
expr = expr.format(st, s, s, t, t)
# calculates the new luma value pushing it towards min or max
nval = core.std.Expr([nval, nmax], [expr])
# normalizing val to values from min to max
tmp = core.std.Expr([nval, mini], ['x y +'])
# resizing the image to the output resolution
# applying the new luma value to clip
if dw != ow or dh != oh:
if color in [vs.YUV, vs.YCOCG]:
tmp = core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
return core.resize.Spline36(tmp, dw, dh)
elif ssx > 1 or ssy > 1:
if color in [vs.YUV, vs.YCOCG]:
tmp = core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
return core.resize.Spline36(tmp, dw, dh)
elif color in [vs.YUV, vs.YCOCG]:
return core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
else:
return tmp
which sadly gives me tons or artifacts, even with simply scripts:
https://i.ibb.co/qn70Cpn/psharpen.png
# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import G41Fun
# Loading source using FFMS2
clip = core.ffms2.Source(source="F:/TESTCL~1/files/test.avi",cachefile="E:/Temp/avi_078c37f69bb356e7b5fa040c71584c40_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# sharpening using PSharpen
clip = G41Fun.psharpen(clip=clip, ss_x=2.00, ss_y=2.00)
# Output
clip.set_output()
Anyone know of a working version of this filter?
Cu Selur
G41Fun.py (no clue what happened to the original github for this) contained a psharpen port:
def psharpen(clip, strength=25, threshold=75, ssx=1, ssy=1, dw=None, dh=None):
"""
From https://forum.doom9.org/showthread.php?p=683344 by ilpippo80.
Sharpeing function similar to LimitedSharpenFaster,
performs two-point sharpening to avoid overshoot.
Args:
strength (float) - Strength of the sharpening, 0 to 100.
threshold (float) - Controls "how much" to be sharpened, 0 to 100.
ssx, ssy (float) - Supersampling factor (reduce aliasing on edges).
dw, dh (int) - Output resolution after sharpening.
"""
if not isinstance(clip, vs.VideoNode):
raise TypeError("psharpen: This is not a clip!")
if clip.format.sample_type != vs.INTEGER:
raise TypeError("psharpen: clip must be of integer sample type")
if clip.format.color_family == vs.COMPAT:
raise TypeError("psharpen: COMPAT color family is not supported!")
color = clip.format.color_family
ow = clip.width
oh = clip.height
ssx = max(ssx, 1.0)
ssy = max(ssy, 1.0)
strength = min(max(strength, 0), 100)
threshold = min(max(threshold, 0), 100)
xss = m4(ow * ssx)
yss = m4(oh * ssy)
if dw is None:
dw = ow
if dh is None:
dh = oh
# oversampling
if ssx > 1 or ssy > 1:
clip = core.resize.Spline36(clip, xss, yss)
tmp = core.std.ShufflePlanes(clip, [0], vs.GRAY) if color in [vs.YUV, vs.YCOCG] else clip
# calculating the max and min in every 3*3 square
maxi = core.std.Maximum(tmp)
mini = core.std.Minimum(tmp)
# normalizing max and val to values from 0 to (max-min)
nmax = core.std.Expr([maxi, mini], ['x y -'])
nval = core.std.Expr([tmp, mini], ['x y -'])
# initializing expression used to obtain the output luma value
s = strength / 100
t = threshold / 100
st = 1 - (s / (s + t - s * t))
expr = 'x y / 2 * 1 - abs {} < {} 1 = x y 2 / = 0 y 2 / ? x y / 2 * 1 - abs 1 {} - / ? x y / 2 * 1 - abs 1 {} - * {} + ? x y 2 / > 1 -1 ? * 1 + y * 2 /'
expr = expr.format(st, s, s, t, t)
# calculates the new luma value pushing it towards min or max
nval = core.std.Expr([nval, nmax], [expr])
# normalizing val to values from min to max
tmp = core.std.Expr([nval, mini], ['x y +'])
# resizing the image to the output resolution
# applying the new luma value to clip
if dw != ow or dh != oh:
if color in [vs.YUV, vs.YCOCG]:
tmp = core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
return core.resize.Spline36(tmp, dw, dh)
elif ssx > 1 or ssy > 1:
if color in [vs.YUV, vs.YCOCG]:
tmp = core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
return core.resize.Spline36(tmp, dw, dh)
elif color in [vs.YUV, vs.YCOCG]:
return core.std.ShufflePlanes([tmp, clip], [0, 1, 2], color)
else:
return tmp
which sadly gives me tons or artifacts, even with simply scripts:
https://i.ibb.co/qn70Cpn/psharpen.png
# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import G41Fun
# Loading source using FFMS2
clip = core.ffms2.Source(source="F:/TESTCL~1/files/test.avi",cachefile="E:/Temp/avi_078c37f69bb356e7b5fa040c71584c40_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# sharpening using PSharpen
clip = G41Fun.psharpen(clip=clip, ss_x=2.00, ss_y=2.00)
# Output
clip.set_output()
Anyone know of a working version of this filter?
Cu Selur