View Full Version : Limited sharpen faster


Serbianboss
16th September 2006, 13:20
Where can downloaded limited sharpen fasterAnd where can read some documentation for that filter.I search but didnt found.

thanks

foxyshadis
16th September 2006, 14:28
http://www.avisynth.org/mediawiki/wiki/LimitedSharpen

Serbianboss
16th September 2006, 17:34
Which another sharpen filter is good because limitedsharpen faster works with yv12 and i work with rgb/yuy2 dv avi material.

Didée
16th September 2006, 18:26
LS works also with YUY2 input.

Besides, "sharpen(1)" accepts all colorspaces, and is very fast. :)

Serbianboss
16th September 2006, 18:33
I try limited sharpen faster but it dosnt work.

I downloaded mask tools 2 and LimitedSharpenFaster.avs and still dosnt work.

Does sharpen(1) is another sharp filter?

Didée
16th September 2006, 18:53
I try limited sharpen faster but it dosnt work.
It does work.

Sharpen() is Avisynth's internal sharpen filter.

Earth is not a disk.

Boulder
16th September 2006, 19:59
Why don't you simply use Cedocida to decode the DV video and get proper YV12 data?

Pookie
16th September 2006, 20:14
I agree with Didée. Sharpen(1).Sharpen(1) :D


SerbianBoss, maybe you can describe the error more than "it doesn't work".

RogueSquadron
18th September 2006, 20:07
i tried to work around with LSF but it wudnt let me start off :( i keep getting this pop-up even though i re-checked with the script umpteen times

http://img526.imageshack.us/img526/9950/untitledlw7.jpg


PS: i saved the LSf.avs in unicode format wil it be a issue?

Serbianboss
19th September 2006, 00:48
I agree with Didée. Sharpen(1).Sharpen(1) :D


SerbianBoss, maybe you can describe the error more than "it doesn't work".

Sorry for late answer.

My source is dv avi(interlace,pal):

i am using this:


# LimitedSharpen() ( a modded version, 29 Oct 2005 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
#
## - MODIFIED version using MaskTools 2.0

function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#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
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_makediff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale

return last
}


and using this script:


LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("PeachSmoother")
LoadPlugin("LeakKernelDeint.dll")
LoadPlugin("mt_masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")
avisource("C:\Documents and Settings\Nenad\My Documents\111.avi")
crop(8,4,-8,-12)
ConvertToYuY2(interlaced=true)
AssumeBFF()
LeakKernelBob(Order=0,threshold=3)
PeachSmoother(NoiseReduction = 80, Stability = 25, Spatial = 200)
limitedsharpenfaster()
AssumeBFF()
SeparateFields()
SelectEvery(4,0,3)
Weave()
AddBorders(8,8,8,8)


and error i got is:

http://img126.imageshack.us/img126/2307/untitledvx6.jpg (http://imageshack.us)

What can be problem?

Pookie
19th September 2006, 01:02
Probably your version of Removegrain. Make sure it is greater than v0.9.

Serbianboss
19th September 2006, 07:08
I succeed i downloaded latest remowegrain from wiki.

Can someone tell's me basic parametars for limited sharpen faster?
For example: little sharpening and stronger sharpening.

I will be using on this script:


LoadPlugin("RemoveGrainSSE3.dll")
LoadPlugin("PeachSmoother")
LoadPlugin("LeakKernelDeint.dll")
LoadPlugin("mt_masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")
avisource("C:\Documents and Settings\Nenad\My Documents\111.avi")
crop(8,4,-8,-12)
ConvertToYuY2(interlaced=true)
AssumeBFF()
LeakKernelBob(Order=0,threshold=3)
PeachSmoother(NoiseReduction = 80, Stability = 25, Spatial = 200)
limitedsharpenfaster()
AssumeBFF()
SeparateFields()
SelectEvery(4,0,3)
Weave()
AddBorders(8,8,8,8)

Didée
19th September 2006, 08:11
Can someone tell's me basic parametars for limited sharpen faster?
For example: little sharpening and stronger sharpening.

Little : LimitedSharpenFaster(strength=1)
Strong : LimitedSharpenFaster(strength=1024)

Default is strength=100.

Audionut
19th September 2006, 09:58
There is a big thread here, strangely enough, titled, Limitedsharpen.

As Always. Use Search.

Serbianboss
19th September 2006, 12:33
It's simes that limited sharpen faster produce little blocking.Maybe i am wrong but i little noticed that picture is little blocky when i put
LimitedSharpenFaster(strength=300)

Does is need to set some mode for LSF ?

Didée
19th September 2006, 13:18
It's simes that limited sharpen faster produce little blocking

Not quite. LS/LSF will not "produce" blocking. It's the source that already has the blocking in it, and this inherent blocking is enhanced by the sharpening process, so that it becomes more noticeable.

That's completely normal. Despite all the features, LS/F still is kind of a "generic" sharpener, i.e. it won't try make an intelligent distinction between "detail that should be sharpened" and "artefacts that should not be sharpened". It just looks for pixel differences, and enhances them in "the LimitedSharpen way". And blocking is nothing else than a certain appearance of pixel differences. ;)

From the side of LimitedSharpen, choices to reduce this sideffect are:

- use "overshoot=0"
- use "soft=x" (try e.g. x=40, possible range is 0..100.)
- use a deblocker before applying LimitedSharpen.


Another way is to use "indirect processing". If you feel the source itself could do without any deblocking, but block artefacts become visible after sharpening, then you could use SeeSaw like

a = last
b = a.SomeSuitedDeblocking()
SeeSaw( a,b, NRlimit=0,NRlimit2=99, bias=100, [..other setting..] )

This way, the source will not get any deblocking applied to (because of NRlimit=0), BUT the "result of sharpening" will be obtained from a de-blocked source.
(Same principle can be done with denoising instead of deblocking, and that's the "noise-bypass-sharpening" functionality of SeeSaw.)


BTW, the "manual way" to do this SeeSaw-thingy with LimitedSharpen would be:

a = last
b = a.SomeSuitedDeblocking()
c = b.LimitedSharpen( settings )
result = a.mt_makediff( mt_makediff(b,c), U=2,V=2 )


See, there are *so many* different ways to do something, and/or to modify a given way of processing according to circumstances ... you just can't cover all possibilities with some simple functions.

Understanding a problem, then acting accordingly, that's a strategy. :)

Serbianboss
19th September 2006, 22:30
Didée thanks for explanation.

I will study option in LSF and if something isn't clear to me i will aks.
And one thing: LSF is very fast filter.

Selur
14th October 2006, 11:54
avisynth.org is down (search forum, there are a bunch of threads about it)

LeMoi
3rd November 2006, 23:33
Where can i find a mirror for LSF, please ? :)

Pookie
3rd November 2006, 23:42
I think this is the correct one (file is dated 14 Jan 2006)

# LimitedSharpen() ( a modded version, 29 Oct 2005 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
#
## - MODIFIED version using MaskTools 2.0

function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#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
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_makediff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale

return last
}