View Full Version : Sharpen function - nasty artifacts
anton_foy
5th May 2022, 22:20
I made a sharpen function called BSharp which works well in most cases and pretty fast. But the culprit that gives me the artifacts seen in the image below seems to be internal sharpen. Does someone have an idea how to get rid of these nasty artifacts yet still retain the sharpening?
Function:
function bsharp(clip c, float "str", float "pblur"){
str = Default(str, 0.5)
pblur = Default(pblur, 0.7)
B = merge(c,c.removegrain(20),(pblur))
S = B.sharpen(1.0).sharpen(str)
M = C.greyscale().ex_levels(47,0.76,170)
mt_merge(c,s,m,luma=true,Y=3,U=2,V=2)
return last
}
Artifacts (https://ibb.co/7ryxJ7N)
Reel.Deel
5th May 2022, 22:25
Not sure if this has something to do with it, but luma=true forces chroma processing in mt_merge. So U=2,V=2 does not do anything. Set luma to false and see if it helps any.
anton_foy
5th May 2022, 23:39
Set luma to false and see if it helps any.
Thanks it actually made it better in other ways but the main problem still remains. Maybe I should choose another sharpener, but which?
Reel.Deel
6th May 2022, 13:20
Maybe I should choose another sharpener, but which?
Possibly, per the wiki: "Chaining calls to Sharpen is not a good idea, as the image quickly deteriorates."
anton_foy
6th May 2022, 15:15
Possibly, per the wiki: "Chaining calls to Sharpen is not a good idea, as the image quickly deteriorates."
Perfect thanks I believe that is the problem isolated then. Now to find another stronger sharpener.
VoodooFX
6th May 2022, 15:26
Now to find another stronger sharpener.
Try all 9000 of them: http://avisynth.nl/index.php/External_filters#Sharpeners
anton_foy
6th May 2022, 22:46
Try all 9000 of them: http://avisynth.nl/index.php/External_filters#Sharpeners
Thanks!
StainlessS
7th May 2022, 15:58
"Chaining calls to Sharpen is not a good idea, as the image quickly deteriorates."
Indeed, see last three images of colorbars below
Below StringRepeater() script function does not use RT_Stats, but this a good as any place to put it, perhaps of use.
Function StringRepeater(String BaseS, String RepS, int n) { # https://forum.doom9.org/showthread.php?p=1878193#post1878193
# Add n instances of repeat string RepS, to base string BaseS.
return (n>=1) ? StringRepeater(BaseS+RepS,RepS,n-1):BaseS
}
Demo
# DEMO USE # For AVS+, GScript stuff commented out
# GScript("""
SSS=""
for(i=0,8) {
S=StringRepeater("MyClip",".Blur(1.58,1.58)",i)
SSS=RT_String("%s%d] %s\\n",SSS,i,S)
}
Colorbars(width=1024,Height=240).Subtitle(SSS,lsp=0)
# """) # End Of GScript
https://i.postimg.cc/cJs1XvNT/String-Repeater.jpg (https://postimages.org/)
EDIT: For above demo, could then do eg Eval(S) to to use one of the result strings.
eg
MyClip=Colorbars
Eval(StringRepeater("MyClip",".Blur(1.58,1.58)",10)) # for 10 iterations of blur(1.58,1.58), where 1.58 is MAX possible blur.
EDIT: Or Sharpen 10 times at max
MyClip=Colorbars
Return Eval(StringRepeater("MyClip",".Sharpen(1.0,1.0)",10)) # for 10 instances of Sharpen at max possible.
Sharpen @ Max x 10.
https://i.postimg.cc/XY7Bvj2Z/Sharpen10.jpg (https://postimages.org/)
EDIT: Sharpen @ Max x 50.
https://i.postimg.cc/2yVXmRPg/Sharpen50.jpg (https://postimages.org/)
EDIT: Sharpen @ Max x 250.
https://i.postimg.cc/vH9LFZ45/Sharpen250.jpg (https://postimages.org/)
EDIT: Have not tried to max it out to find where stack overflow occurs, but for some other function many years ago a recursive
function using GScript maxed out at about 450 recurses, and error abort (probably using avs v2.58).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.