# LimitedSharpen() # # A multi-purpose sharpener by Didée # function LS_schnell_schnell( clip clp, \ float "ss_x", float "ss_y", int "dest_x", int "dest_y", \ int "Smode", int "strength", int "radius" ) { ox = clp.width oy = clp.height ss_x = default( ss_x, 1.5 ) ss_y = default( ss_y, 1.5 ) dest_x = default( dest_x, ox ) dest_y = default( dest_y, oy ) Smode = default( Smode, 3 ) strength = Smode==1 \ ? default( strength, 160 ) \ : default( strength, 100 ) strength = Smode==2&&strength>100 ? 100 : strength radius = default( radius, 2 ) #radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again xxs=round(ox*ss_x/8)*8 yys=round(oy*ss_y/8)*8 clp.isYV12() ? clp : clp.converttoyv12() ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last tmp = last dark_limit = tmp.inpand() bright_limit = tmp.expand() minmaxavg = yv12lutxy(bright_limit,dark_limit,yexpr="x y + 2 /") Str=string(float(strength)/100.0) normsharp = Smode==1 ? tmp.unsharpmask(strength,radius,0) \ : Smode==2 ? tmp.sharpen(float(strength)/100.0) \ : yv12lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +",U=2,V=2) repair(normsharp,tmp,mode=1) (ss_x != 1.0 || ss_y != 1.0) \ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last clp.isYV12() ? last \ : lanczosresize(clp, dest_x,dest_y).mergeluma(last.converttoyuy2()) return last } #