View Full Version : Problems with sharpen in function
anton_foy
11th September 2021, 13:27
Hi I try to make a function and I seem to be missing something here. I get the error "invalid arguments to 'sharpen'".
Script:
function TOPSHARP(clip Input, float "sharpness")
{
su=Defined(sharpness)
sharpness=su ? sharpness : 0.7
shrp = sharpen(sharpness)
clip = last
smask = clip.coloryuv(autogain=true).removegrain(20,-1).removegrain(20,-1).sharpen(1.0).ex_edge(mode="kirsch")
\ .mt_expand(paramscale="i16").mt_expand(paramscale="i16").removegrain(20,-1).removegrain(20,-1)
mt_merge(clip,shrp,smask, Y=3,U=2,V=2, paramscale="i16")
return last
}
I have even tried to just set function TOPSHARP(clip Input) and shrp = sharpen(0.7)
but it still gives me this error.
Thanks
wonkey_monkey
11th September 2021, 14:47
There is no implicit clip here - you haven't left a clip on the "stack", so to speak, anywhere above the call to Sharpen - so you need to tell Sharpen which clip you're applying it to.
Either put "Input" on a line by itself to make the implicit last clip, or use
shrp = sharpen(Input, sharpen)
Although I'm not sure what "clip = last" will do in these circumstances.
anton_foy
11th September 2021, 15:09
There is no implicit clip here - you haven't left a clip on the "stack", so to speak, anywhere above the call to Sharpen - so you need to tell Sharpen which clip you're applying it to.
Either put "Input" on a line by itself to make the implicit last clip, or use
shrp = sharpen(Input, sharpen)
Although I'm not sure what "clip = last" will do in these circumstances.
Thank you Wonkey_Monkey! Yes this did it but then it gives me another error: "invalid arguments to function 'coloryuv'".
I am trying to learn how to make a function and with Topsharp I want to use the sharpened clip shrp = sharpen(Input, sharpen) to mask smask = clip.coloryuv(autogain=true).removegrain(20,-1).removegrain(20,-1).sharpen(1.0).ex_edge(mode="kirsch")
\ .mt_expand(paramscale="i16").mt_expand(paramscale="i16").removegrain(20,-1).removegrain(20,-1) with edgemask and overlay onto the original clip clip = last and merge mt_merge(clip,shrp,smask, Y=3,U=2,V=2, paramscale="i16") them together. I probably do this incorrectly but I try to find out how.
EDIT:
It works now! Thanks again!
clip = Input
shrp = sharpen(Input, sharpen)
smask = clip.coloryuv(autogain=true).removegrain(20,-1).removegrain(20,-1).sharpen(1.0).ex_edge(mode="kirsch")
\ .mt_expand(paramscale="i16").mt_expand(paramscale="i16").removegrain(20,-1).removegrain(20,-1)
mt_merge(clip,shrp,smask, Y=3,U=2,V=2, paramscale="i16")
return last
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.