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. |
2nd December 2007, 03:52 | #1 | Link |
Registered User
Join Date: Feb 2004
Posts: 1,348
|
Super Slow Sharpen
Code:
#version 0.1, optimizations by Didée function halomaskM(clip c, int "hthr", int "hbias", int "agmrad"){ hthr = default(hthr, 256) hbias = default(hbias, -128) agmrad = default(agmrad, 1) s = c Mblur = (agmrad==1) ? s.removegrain(4,-1) : s.Quantile(radius_y=agmrad,radius_u=-1,radius_v=-1) gblur = (agmrad<=5) ? s.binomialblur(vary=agmrad, varc=0) : s.gaussianblur(vary=agmrad, varc=0) maskM = mt_lutxy(Mblur, Gblur, "y x - abs "+string(hthr)+" * "+string(hbias)+" +", U=1, V=1) return(maskM)} function halomaskMR(clip c, int "hthr", int "hbias"){ hthr = default(hthr, 256) hbias = default(hbias, -128) s = c Ablur = s.removegrain(4) gblur = s.gaussianblur(vary=1, varc=0) mask3 = mt_lutxy(Ablur, Gblur, "y x - abs "+string(hthr)+" * "+string(hbias)+" +", U=1, V=1) return(mask3)} function SSW(clip c){ c#.unsharp() w = width h = height spline36resize(w*3, h*3) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99) spline36resize(w, h)} function SSSharp(clip c, float "rad", bool "ssw", float "strength", int "iter", bool "ss", int "denoise"){ rad = default(rad, 0.25) ssw = default(ssw, true) strength = default(strength, 4) iter = default(iter, 1) ss = default(ss, true) denoise = default(denoise, iter) c w = width(c) h = height(c) sswc = ssw ? c.ssw() : c (iter >= 1) ? MT_Merge(unsharp(vary=rad, varc=1, strength=strength), sswc, spline36resize((ss ? w*4 : w), (ss ? h*4 : h)).halomaskM(hbias=-128, hthr=256, agmrad=(ss ? round(rad*4) : round(rad))).spline36resize(w, h)) : last (denoise >=1) ? degrainmedian(mode=3).dctfun4b(2,2) : last (iter >= 2) ? MT_Merge(unsharp(vary=rad, varc=1, strength=strength), sswc, spline36resize((ss ? w*4 : w), (ss ? h*4 : h)).halomaskM(hbias=-128, hthr=256, agmrad=(ss ? round(rad*4) : round(rad))).spline36resize(w, h)) : last (denoise >=2) ? degrainmedian(mode=3).dctfun4b(2,2) : last (iter >= 3) ? MT_Merge(unsharp(vary=rad, varc=1, strength=strength), sswc, spline36resize((ss ? w*4 : w), (ss ? h*4 : h)).halomaskM(hbias=-128, hthr=256, agmrad=(ss ? round(rad*4) : round(rad))).spline36resize(w, h)) : last (denoise >=3) ? degrainmedian(mode=3).dctfun4b(2,2) : last (iter >= 4) ? MT_Merge(unsharp(vary=rad, varc=1, strength=strength), sswc, spline36resize((ss ? w*4 : w), (ss ? h*4 : h)).halomaskM(hbias=-128, hthr=256, agmrad=(ss ? round(rad*4) : round(rad))).spline36resize(w, h)) : last (denoise >=4) ? degrainmedian(mode=3).dctfun4b(2,2) : last return(last) } example usage: Code:
source = MPEG2Source("J:\GITS_D1\VIDEO_TS\GITS.d2v", cpu=0, info=3).colormatrix(hints=true, interlaced=true).crop(8,8,-8,-8).assumetff() Deint = Source.securedeint().selecteven IVTC = source.TFM(mode=7, clip2=deint, pp=7, slow=2, d2v="J:\GITS_D1\VIDEO_TS\GITS.d2v") IVTC SSSharp(ssw=true, iter=1, strength=1, rad=1) SSSharp(ssw=true, iter=2, strength=3) deen("m2d", 20, 12, 0) no processing Last edited by *.mp4 guy; 3rd December 2007 at 20:52. |
2nd December 2007, 10:04 | #3 | Link |
Registered User
Join Date: Feb 2004
Posts: 1,348
|
They are both part of the variableblur plugin by tsp.
|
2nd December 2007, 13:28 | #4 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
There is a possible speed improvement, target is MedianBlur. MedianBlur alas is rather slow compared to the available faster alternatives.
MedianBlur(1) can be replaced by RemoveGrain(4). That's 2.5 to 3 times faster. With radii > 1, MedianBlur(r) can be replaced by Quantile(), which is part of kassandro's new RemoveGrainHD filter package. The parameters are a bit unintuitive at first glance, however Quantile runs at least 2.5 times as fast as MedianBlur, if not more. Not sure how much impact this has in the context of the whole script (it seems very very slow just by looking at the script's code), but at least this particular filter is an obvious target for optimization.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
2nd December 2007, 23:01 | #5 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
also using binomialBlur instead of gaussianblur might be worth a try.
__________________
Get my avisynth filters @ http://www.avisynth.org/tsp/ |
3rd December 2007, 05:47 | #6 | Link |
Registered User
Join Date: Feb 2004
Posts: 1,348
|
@ tsp
How big is the difference between a vary=1 guassianblur and a var=1 binomialblur? @Didée Do you know if removegrain(4) has higher or lower ram usage then medianblur(1)? [edit] I tried to implement removegrain instead of medianblur for aplicable radii, but avisynth is barfing on all of the if : then's, I might just split out a separate function for it. Last edited by *.mp4 guy; 3rd December 2007 at 06:26. |
3rd December 2007, 13:17 | #7 | Link | |||
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Quote:
Quote:
Quote:
Code:
s = c # Ablur = s.medianblur(agmrad) Ablur = (agmrad==1) ? s.removegrain(4,-1) : s.Quantile(radius_y=agmrad,radius_u=-1,radius_v=-1) # gblur = s.gaussianblur(vary=agmrad, varc=0) gblur = (agmrad<=5) ? s.binomialblur(vary=agmrad, varc=0) : s.gaussianblur(vary=agmrad, varc=0) mask3 = mt_lutxy(Ablur, Gblur, "y x - abs "+string(hthr)+" * "+string(hbias)+" +", U=1, V=1) Measures with SetMemoryMax(300) on a 2.8GHz Core2, 720x576 PAL smaple: (Note that it's frames per *minute* ...) SSSharp() original: 23fpm modded: 53 fpm SSSharp(rad=3,ssw=true,iter=4) original: 3.4 fpm modded: 6.5 fpm Those were quick'n dirty tests - short sample, only one repetition, no reboot inbetween, etc. Short of time, sorry. Still, it seems that the speed is roughly doubled by those changes, perhaps even more.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|||
4th December 2007, 23:37 | #9 | Link |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Wow! After seeing the long aWarpSharp chain, I was a bit shocked... But looking at your example n considering how blurry the source is, the result surprises me... Looks almost like some sort of deconvolution! How does it look in motion? [Is the effect "stable"?] Can you give some more samples? [Different content, less blurry -> less filtering, a source with higher resolution...] :]
Thx n' Bye Last edited by Soulhunter; 4th December 2007 at 23:46. |
4th December 2007, 23:53 | #10 | Link | |
Registered User
Join Date: Feb 2004
Posts: 1,348
|
Quote:
I'm currently running a very ram hungry script, it should be done soon, and when it is I'll edit this post with a few more examples. [edit] script: Code:
MPEG2Source("J:\THANKYOUFORSMOKING_WS\VIDEO_TS\TYFS.d2v", cpu=0, info=3).colormatrix(hints=true).crop(0, 60, 0, -60) SSSharp(denoise=1, iter=2, ssw=true) SSSharp, no processing SSSharp, no processing Keep in mind that these examples are actualy very oversharp, and wouldn't look good after being scaled up to fullscreen, realistically this source doesn't need such strong sharpening. Last edited by *.mp4 guy; 5th December 2007 at 01:00. |
|
6th December 2007, 17:27 | #11 | Link |
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,556
|
I vote for calling it GlacialSharpen, though thanks to Didée it's no longer EpochSharpen. (EpicSharpen?) Works great for scans, though waiting 10 seconds every attempt while finding the right settings can be rather frustrating.
|
12th January 2008, 03:15 | #19 | Link |
Registered User
Join Date: Aug 2006
Location: Region 3 with NDS Encryption
Posts: 355
|
I do not compute, seriously I dont understand, can you give a step by step guide please, thank you. I hope it's not too troublesome. Also I get this error -> unsharp unknown command
|
Thread Tools | Search this Thread |
Display Modes | |
|
|