Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
LSFmod [v1.9 - Update 2009/10/05]
Code:
################################################################################################ ### ### ### LimitedSharpenFaster MOD : function LSFmod() ### ### ### ### Modded Version by LaTo INV. ### ### ### ### v1.9 - 05 October 2009 ### ### ### ################################################################################################ ### ### ### +--------------+ ### | DEPENDENCIES | ### +--------------+ ### ### -> Masktools (v2a36) ### -> Removegrain (v1.0pre) ### -> Warpsharp (2003.11.03) [for Smode=1] ### -> Variableblur (v0.30) [for Smode=2] ### ### ### ### +-------+ ### | USAGE | ### +-------+ ### ### LSFmod( strength, Smode, Smethod, kernel, ### preblur, secure, source, ### Szrp, Spwr, SdmpLo, SdmpHi, ### Lmode, overshoot, undershoot, overshoot2, undershoot2, ### soft, soothe, keep, ### edgemode, edgemaskHQ, ### ss_x, ss_y, dest_x, dest_y, ### show, screenW, screenH, ### defaults ) ### ### ### ### +---------+ ### | GENERAL | ### +---------+ ### ### strength [int] ### -------------- ### Strength of the sharpening ### ### Smode [int: 1,2,3,4,5] ### ---------------------- ### Sharpen mode: ### =1 : Unsharp masking (from warpsharp) ### =2 : Unsharp masking (from variableblur) ### =3 : Range sharpening ### =4 : Nonlinear sharpening (original version) ### =5 : Nonlinear sharpening (corrected version) ### ### Smethod [int: 1,2,3] ### -------------------- ### Sharpen method: (only used in Smode=3,4,5) ### =1 : 3x3 kernel ### =2 : Min/Max ### =3 : Min/Max + 3x3 kernel ### ### kernel [int: 11,12,19,20] ### ------------------------- ### Kernel used in Smethod=1&3 ### In strength order: + 19 > 12 >> 20 > 11 - ### ### ### ### +---------+ ### | SPECIAL | ### +---------+ ### ### preblur [string: "ON","OFF",...] ### -------------------------------- ### Mode to avoid noise sharpening & ringing (only used in Smode=3,4,5) ### "ON" is sufficient to prevent ringing, but to prevent noise sharpening you should set your own denoiser ### Usage: LSFmod(preblur="YourFavoriteDenoiser()") ### Example: LSFmod(preblur="FFT3Dfilter(sigma=4,plane=0)") ### ### ### secure [bool] ### ------------- ### Mode to avoid banding & oil painting (or face wax) effect of sharpening ### (only used in Smode=3,4,5) ### ### source [clip] ### ------------- ### If source is defined, LSFmod doesn't sharp more a denoised clip than this source clip ### In this mode, you can safely set Lmode=0 & PP=off ### Usage: denoised.LSFmod(source=source) ### Example: last.FFT3Dfilter().LSFmod(source=last,Lmode=0,soft=0) ### ### ### ### +----------------------+ ### | NONLINEAR SHARPENING | ### +----------------------+ ### ### Szrp [int] ### ---------- ### Zero Point: ### - differences below Szrp are amplified (overdrive sharpening) ### - differences above Szrp are reduced (reduced sharpening) ### ### Spwr [int] ### ---------- ### Power: exponent for sharpener ### ### SdmpLo [int] ### ------------ ### Damp Low: reduce sharpening for small changes [0:disable] ### ### SdmpHi [int] ### ------------ ### Damp High: reduce sharpening for big changes [0:disable] ### ### ### ### +----------+ ### | LIMITING | ### +----------+ ### ### Lmode [int: ...,0,1,2,3,4] ### -------------------------- ### Limit mode: ### <0 : Limit with repair (ex: Lmode=-1 --> repair(1), Lmode=-5 --> repair(5)...) ### =0 : No limit ### =1 : Limit to over/undershoot ### =2 : Limit to over/undershoot on edges and no limit on not-edges ### =3 : Limit to zero on edges and to over/undershoot on not-edges ### =4 : Limit to over/undershoot on edges and to over/undershoot2 on not-edges ### ### overshoot [int] ### --------------- ### Limit for pixels that get brighter during sharpening ### ### undershoot [int] ### ---------------- ### Limit for pixels that get darker during sharpening ### ### overshoot2 [int] ### ---------------- ### Same as overshoot, only for Lmode=4 ### ### undershoot2 [int] ### ----------------- ### Same as undershoot, only for Lmode=4 ### ### ### ### +-----------------+ ### | POST-PROCESSING | ### +-----------------+ ### ### soft [int: -2,-1,0...100] ### ------------------------- ### Soft the sharpening effect (-1 = old autocalculate, -2 = new autocalculate) ### ### soothe [bool] ### ------------- ### =true : Enable soothe temporal stabilization ### =false : Disable soothe temporal stabilization ### ### keep [int: 0...100] ### ------------------- ### Minimum percent of the original sharpening to keep (only with soothe=true) ### ### ### ### +-------+ ### | EDGES | ### +-------+ ### ### edgemode [int: -1,0,1,2] ### ------------------------ ### =-1 : Show edgemask ### = 0 : Sharpening all ### = 1 : Sharpening only edges ### = 2 : Sharpening only not-edges ### ### edgemaskHQ [bool] ### ----------------- ### =true : Original edgemask ### =false : Faster edgemask ### ### ### ### +------------+ ### | UPSAMPLING | ### +------------+ ### ### ss_x ; ss_y [float] ### ------------------- ### Supersampling factor (reduce aliasing on edges) ### ### dest_x ; dest_y [int] ### --------------------- ### Output resolution after sharpening (avoid a resizing step) ### ### ### ### +-------+ ### | DEBUG | ### +-------+ ### ### show [bool] ### ----------- ### Show debug clip & informations ### ### screenW ; screenH [int] ### ----------------------- ### Screen resolution (for show clip) ### ### ### ### +----------+ ### | SETTINGS | ### +----------+ ### ### defaults [string: "old" or "slow" or "fast"] ### -------------------------------------------- ### = "old" : Reset settings to original version (output will be THE SAME AS LSF) ### = "slow" : Enable SLOW modded version settings ### = "fast" : Enable FAST modded version settings ### --> /!\ [default:"fast"] ### ### ### defaults="old" : - strength = 100 ### ---------------- - Smode = 3 ### - Smethod = Smode==3?2:1 ### - kernel = 11 ### ### - preblur = "OFF" ### - secure = false ### - source = undefined ### ### - Szrp = 16 ### - Spwr = 2 ### - SdmpLo = strength/25 ### - SdmpHi = 0 ### ### - Lmode = 1 ### - overshoot = 1 ### - undershoot = overshoot ### - overshoot2 = overshoot*2 ### - undershoot2 = overshoot2 ### ### - soft = 0 ### - soothe = false ### - keep = 25 ### ### - edgemode = 0 ### - edgemaskHQ = true ### ### - ss_x = Smode==3?1.50:1.25 ### - ss_y = ss_x ### - dest_x = ox ### - dest_y = oy ### ### - show = false ### - screenW = 1280 ### - screenH = 1024 ### ### ### defaults="slow" : - strength = 100 ### ----------------- - Smode = 5 ### - Smethod = 3 ### - kernel = 11 ### ### - preblur = "OFF" ### - secure = true ### - source = undefined ### ### - Szrp = 16 ### - Spwr = 4 ### - SdmpLo = 4 ### - SdmpHi = 48 ### ### - Lmode = 4 ### - overshoot = strength/100 ### - undershoot = overshoot ### - overshoot2 = overshoot*2 ### - undershoot2 = overshoot2 ### ### - soft = -2 ### - soothe = true ### - keep = 20 ### ### - edgemode = 0 ### - edgemaskHQ = true ### ### - ss_x = 1.50 ### - ss_y = ss_x ### - dest_x = ox ### - dest_y = oy ### ### - show = false ### - screenW = 1280 ### - screenH = 1024 ### ### ### defaults="fast" : - strength = 100 ### ----------------- - Smode = 3 ### - Smethod = 2 ### - kernel = 11 ### ### - preblur = "OFF" ### - secure = true ### - source = undefined ### ### - Szrp = 16 ### - Spwr = 4 ### - SdmpLo = 4 ### - SdmpHi = 48 ### ### - Lmode = 1 ### - overshoot = strength/100 ### - undershoot = overshoot ### - overshoot2 = overshoot*2 ### - undershoot2 = overshoot2 ### ### - soft = 0 ### - soothe = true ### - keep = 20 ### ### - edgemode = 0 ### - edgemaskHQ = false ### ### - ss_x = 1.25 ### - ss_y = ss_x ### - dest_x = ox ### - dest_y = oy ### ### - show = false ### - screenW = 1280 ### - screenH = 1024 ### ################################################################################################ Update 2009.10.05 : LSFmod v1.9 v1.9: tweaked settings default preset is now defaults="fast" /!\ v1.8: changed preblur to allow more tweaking (bool->string) tweaked settings cleaned the code updated documentation v1.7: changed Smethod=4 to "source" v1.6: added preblur option added new Smethod=4 v1.5: fixed LUT expression (thanks to Didée) changed Smethod to Smethod+secure v1.4: changed defaults="new" to defaults="slow" & defaults="fast" added show parameter cleaned a little the code v1.3: changed a little Smethod=3&5 (same effect, but more precise) added new calculation for soft (soft=-2) [default on] added warning about bad settings (no more silent) updated the documentation v1.2: added new Lmode<0 (limit with repair) added 2 new Smode (unsharp masking) changed Smode order: now old Smode3-4 is new Smode3-4 to avoid mistake v1.1: fixed a bug with dest_x!=ox or dest_y!=oy replaced Lfactor by over/undershoot2 v1.0: deleted old Smode(1-4), added new Smode(1-3) & Smethod(1-5) added parameters for nonlinear sharpening (Szrp,Spwr,SdmpLo,SdmpHi) corrected the nonlinear formula added new Lmode 2 & 4 + fixed Lmode 0 added faster edgemask added soothe temporal stabilization, 2 parameters: soothe & keep replaced lanczosresize by spline36resize moved "strength" parameter (first place) deleted wide, special and exborder changed some code (cosmetic) added "defaults" parameter (to switch between original and modded version) added documentation Last edited by LaTo; 3rd June 2010 at 17:57. |
![]() |
![]() |
![]() |
#2 | Link |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
A small mod (with new options, improvements...) needed for MCTemporalDenoise v1.0.00...
![]() Speed comparaison (with v1.9): Code:
LimitedSharpenFaster() = 17.4 fps LSFmod(defaults="fast") = 16.8 fps LSFmod(defaults="slow") = 7.6 fps Last edited by LaTo; 5th October 2009 at 18:02. |
![]() |
![]() |
![]() |
#3 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
w00t, LaTo does it again
![]() so atm I'm using LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,strength=40) an improved(speed-wise? PQ-wise?) LSFmod call would be : LSFmod(Smode=3,ss_x=1.0,ss_y=1.0,strength=40) ? I dunno what do to with Smethod... any chance you could use the limitedsupport.dll for realtime speed increase ? ![]() EDIT: w00ps, LSF is 310fps, LSFmod is 113 ![]() Last edited by pitch.fr; 11th November 2008 at 17:10. |
![]() |
![]() |
![]() |
#5 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
ok, thanks for the tip!
so LSFmod(Smode=3,Lmode=1,ss_x=1.0,ss_y=1.0,strength=40,soothe=false) is 290fps still a bit slower than the LSF that uses limitedsupport.dll, any chance you could use it ? I might as well mod your script and call it LSFMod2() ![]() is there any point using this LSFMod call over the original one ? you said you "fixed" some stuff if I got it right ![]() |
![]() |
![]() |
![]() |
#6 | Link | ||
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
Quote:
Quote:
![]() |
||
![]() |
![]() |
![]() |
#7 | Link |
Fighting spam with a fish
Join Date: Sep 2005
Posts: 2,724
|
Very interesting. I will have to play with this. Oh, and I can't wait for Didee to spin by. He may offer some great insight.
__________________
FAQs:Bond's AVC/H.264 FAQ Site:Adubvideo Zsmooth - Cross-platform smoothing for Vapoursynth |
![]() |
![]() |
![]() |
#10 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
LaTo, congratulations for the good work.
In the comments write that the "SdmpHi" work in the opposite way than "SdmpLo". Small number for "SdmpHi" mean big reduction for "big sharpening changes" and usefull numbers are 15~30.
__________________
Greece PAL User... |
![]() |
![]() |
![]() |
#11 | Link | ||
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
Quote:
SdmpLo: the higher, the stronger reduction SdmpHi: the lower, the stronger reduction Quote:
new Smode=4 + Smethod=1 is the old Smode=4 new Smode=5 is the same as Smode=4 but with a fix in the formula (no Szrp shift with SdmpLo&SdmpHi!=0) new Smethod=3 is the same as Smethod=2 but softer, I like the result... maybe too soft, so Smethod=5 is the same as Smethod=3 but sharper ![]() Smethod=4 is the sharpest... I will post some screenshot later ![]() Last edited by LaTo; 23rd November 2008 at 19:10. |
||
![]() |
![]() |
![]() |
#12 | Link |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
So, this is some screenshots about Smethod with LSFmod(Smode=1,strength=300,Smethod=X)... (High strength to see better)
Screenshot 1: Smethod=1 Smethod=2 Smethod=3 Smethod=4 Smethod=5 Screenshot 2: Smethod=1 Smethod=2 Smethod=3 Smethod=4 Smethod=5 In order of strength: - 1 < 3 < 5 < 2 < 4 + In order of speed: - 5 < 4 < 3 < 2 < 1 + In order of quality: - 4 < 2 < 1 < 3 < 5 + By default in Limitedsharpenfaster: With Smode=3, similar as Smethod=2 is used... (It's sharp but produce some ugly artefacts... look at the sky in the screenshot1 & in the back of the chair in the screenshot2) With Smode=4, similar as Smethod=1 is used... (It's too soft, especially with a default power at 2 and an "auto SdmpLo" changing with strength) By default in LSFmod: With Smode=1, Smethod=5 is used... (It need a sharp Smethod because this Smode is linear sharpening) With Smode=2&3, Smethod=3 is used... (This Smethod is soft but it's compensated by the Spwr parameter of nonlinear sharpening) Rmq: You can change Skernel to 19, it will be sharper... but there are little artefacts Last edited by LaTo; 28th November 2008 at 18:35. |
![]() |
![]() |
![]() |
#13 | Link |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
About the difference between Smode4 & Smode5 :
![]() ![]() In the original version, when SdmpLo or SdmpHi != 0 the curves don't pass through Szrp... So, in the corrected version, all curves pass through Szrp... It's not very important, but I'm a perfectionnist ![]() EDIT: Oups I forgot the 1/Spwr when I made these graph! It isn't a problem, the principle remains the same... I will correct these graph when I have time ![]() EDIT2: Now all is ok, curves are fixed ![]() Last edited by LaTo; 28th November 2008 at 18:34. |
![]() |
![]() |
![]() |
#15 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
LaTo
1. There is something wrong in your graphs. The bellow graph is from Didee: ![]() Light blue shows "Szp=16, Spower=4, SdampLo=0.01, SdampHi=255". Dark blue shows "Szp=16, Spower=2, SdampLo=3, SdampHi=255" Dark green shows "Szp=16, Spower=4, SdampLo=4, SdampHi=24" 2. From the original SeeSaw function: Sstr = default( Sstr, 1.5 ) Szp = default( Szp, 16 ) # or 16+2 Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 ) SdampLo = default( SdampLo, 5) # Spower+1 SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 ) from your LSFmod: strength = default( strength, Select(num, 100 , 100 ) ) Szrp = default( Szrp, Select(num, 16 , 16 ) ) strength = float(strength)/100.0 Szrp = Szrp == 0 ? 1 : Szrp SdmpLo = default( SdmpLo, Select(num, strength/25 , 4 ) ) If you want explain the differents.
__________________
Greece PAL User... Last edited by Nikos; 13th November 2008 at 00:44. |
![]() |
![]() |
![]() |
#16 | Link | ||
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
Quote:
Quote:
![]() |
||
![]() |
![]() |
![]() |
#17 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
LaTo one more comment.
I prefer separate overshoot value for edges and non edges instead of Lfactor, but this is just my opinion, your mod is nice. Thanks to Didee for the wonderful ideas. Edit Another comment. Code:
### SOFT sharpdiff = mt_makediff(tmp,last,U=1,V=1) sharpdiff = mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1), \ "x 128 - abs y 128 - abs > y "+string(soft)+" * x "+string(100-soft)+" * + 100 / x ?",U=1,V=1) soft==0 ? last : mt_makediff(tmp,sharpdiff,U=1,V=1) (ss_x > 1.0 || ss_y > 1.0) || (dest_x != ox || dest_y != oy) ? spline36resize(dest_x,dest_y) : last ### SOOTHE diff = mt_makediff(clp,last,U=1,V=1) diff2 = diff.temporalsoften(1,255,0,32,2) diff3 = mt_lutxy(diff,diff2,"x 128 - y 128 - * 0 < x 128 - 100 / "+string(keep)+ \ " * 128 + x 128 - abs y 128 - abs > x "+string(keep)+" * y 100 "+string(keep)+" - * + 100 / x ? ?",U=1,V=1) soothe ? mt_makediff(clp,diff3,U=2,V=2) : last.mergechroma(clp) return edgemode!=-1 ? last : edge.spline36resize(dest_x,dest_y).greyscale() }
__________________
Greece PAL User... Last edited by Nikos; 13th November 2008 at 18:31. |
![]() |
![]() |
![]() |
#20 | Link | |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|