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. |
25th April 2007, 16:43 | #1 | Link |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Toon-v0.8x
Code:
# Toon v0.8 # # req: MaskTools151, aWarpSharp function Toon(clip input) { input.Expand().Inpand() Subtract(input,last) Overlay(last, aWarpsharp(depth=32), mode="lighten") lines = last Inpand() Levels(110,1,120,0,255,false) Overlay(lines, BlankClip(last,color=$808080), mask=last) Invert().Greyscale() Subtract(input,last) } Looks familiar, but simplified... >.> Bye Last edited by Soulhunter; 5th July 2007 at 21:12. |
26th April 2007, 17:13 | #2 | Link |
Registered User
Join Date: May 2005
Location: Germany
Posts: 495
|
Nice, I'll test the function if I find the time for it.
This is my older toonmodification (basic idea but different code): Code:
#################### ## LineDarkenToon ## #################### # LineDarkenToon use the idea of mf_toon (0.5) for linedarken. # I wanted a really small fast code like FastLineDarken but with similar output like # mf_toon and this is the result. # # needed filters: # - WarpSharp # - MaskTools v2 # - AWarpSharp # # Common parameters are sstrength, sdboost and srange. # If speed is most important for you, test fast=true. # With fast=true no edgemask will be created, just a simple fast weighting. # But this looks imho still better than FastLineDarken. function linedarken_toon(clip orig, float "sstrength", "sdboost", int "srange", "warpdepth", bool "fast") { ###### parameters ###### sstr = string(default(sstrength, 180)/255.0) srange = default(srange, 0) sdboost = default(sdboost, 1.0) wdepth = default(warpdepth, 8) fast = default(fast, false) ###### filtering ###### sharp = orig.Unsharpmask(300, 4, 0) orig.mt_edge(thy1=3,thy2=255,mode="prewitt",Y=3,V=1,U=1) mt_lut("x "+string(srange)+" + 195 / 1.0 "+string(sdboost)+" / ^ 255 *",U=1,V=1).mt_inflate().mt_inflate().mt_inflate() linemask = mt_lutxy(orig, last, yexpr="300 1 x 255 / - 255 y - * x 1.14 ^ + - "+sstr+" *", uexpr="x", vexpr="x") fast==false ? mt_merge(orig, sharp, linemask, Y=3, U=2, V=2) : \ mt_lutxy(orig,sharp,"x y < 40 y < | x y x - 1 x 255 / - 2 ^ * 1 y 128 / - 4 ^ * "+sstr+" * x + ?",U=2,V=2) final = wdepth<=0 ? last : awarpsharp(last,cm=1,depth=wdepth,blurlevel=1) return final } Last edited by MOmonster; 26th April 2007 at 17:16. |
5th July 2007, 21:12 | #3 | Link |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Update
As there's no feedback, lets make things a bit more interesting!
Here are some screenshots + a updated version... Original: mfToon v0.32 mfToon v0.45 mfToon v0.52 vmToon v0.7 toon v0.81 The function: Code:
# Toon v0.81 # # changelog: fixed global darkening issue # req: MaskTools151, aWarpSharp function Toon(clip input) { input.Expand().Inpand() Subtract(last, input) Overlay(last, aWarpsharp(depth=32), mode="darken") lines = last Expand() Levels(130,1,140,0,255,false) Overlay(BlankClip(last, color=$808080), lines, mask=last) Greyscale() Subtract(input, last) } Bye |
5th July 2007, 23:33 | #4 | Link |
Registered User
Join Date: Jun 2007
Posts: 33
|
Looks very promising. I've been trying vmToon, but it seems extrememly slow - 5 to 6 FPS when running my aviscript in Virtual Dub (full processing mode, XVID output). My computer's fairly fast (AMD Brisbane AM2 @ 2.93Ghz + 1GB of DDR2 @ 840MHz) so I'm thinking there's either an error in my script (don't know how as it's very simple) or vmToon & Deen are just really slow.
Is this faster? I'd like to try it. I'm assuming I just need to (1)copy this into notepad and label it .avsi Code:
# Toon v0.81 # # changelog: fixed global darkening issue # req: MaskTools151, aWarpSharp function Toon(clip input) { input.Expand().Inpand() Subtract(last, input) Overlay(last, aWarpsharp(depth=32), mode="darken") lines = last Expand() Levels(130,1,140,0,255,false) Overlay(BlankClip(last, color=$808080), lines, mask=last) Greyscale() Subtract(input, last) } OT: any suggestions on a good, but not painfully slow denoiser/smoother for anime? I'm currently using Deen "w3d", but I'm thinking there's others that are newer, better and faster. I've see positive comments about MVDegrain2, as well as PeachSmoother + VagueDenoiser. Thanks for all your help. Definite newbie here, and I'm not good with software anyway (hardware's so much easier IMO) |
5th July 2007, 23:46 | #5 | Link |
Registered User
Join Date: Jun 2007
Posts: 33
|
In case it helps, I've attached a jpg of a filtered frame [Deen("w3d",3,5,5), vmToon(strength=32)] vs. the raw image. vmToon seemed to work fine, but there's still a lot of noise left - especially for this section when in motion.
Also, I forgot to ask whether I need to use "ConvertToYV12()" before using Toon v.81 on an avi file. Thanks again for your help. |
6th July 2007, 00:28 | #6 | Link | ||
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Quote:
2. You need MaskTools v 1.51 Quote:
- Deen [Ok and fast] - DCTFun4b [Good and fast] - FrFun7 [Good but slow] - FFT3DFilter [Good but slow] - FrFun3b [Very good but also very slow] Bye Last edited by Soulhunter; 6th July 2007 at 04:45. |
||
6th July 2007, 01:42 | #7 | Link |
Brazilian Anime Ripper
Join Date: Nov 2001
Location: Brazil
Posts: 237
|
As I understand to convert in Masktools 2.0 the script will be:
Code:
# Toon v0.82 # # changelog: fixed global darkening issue # req: MaskTools20, aWarpSharp function Toon(clip input) { input.mt_expand().mt_inpand() Subtract(last, input) Overlay(last, aWarpsharp(depth=32), mode="darken") lines = last mt_expand() Levels(130,1,140,0,255,false) Overlay(BlankClip(last, color=$808080), lines, mask=last) Greyscale() Subtract(input, last) }
__________________
Capture cards: Compro VideoMate Gold+ (Philips SAA7134 based) (not active) Hauppauge PVR 150MCE (not active) ATI TV Wonder Elite (active) |
6th July 2007, 04:33 | #8 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
It won't go into my head why utilization of masktools won't go into mf's head.
Optimization plan: - use masktools v2 (it should be forbidden to still use old v1.5 masktools for "new" scripts) - compact the pedestrian combination of basic filters to the needed minimum Stepwise: Step 0.5: replace ex/inpand with mt_ex/inpand (script posted by acrespo) Step 1 (Step 0.5+0.5) : replace remaining filters with masktools' counterparts: Code:
input.mt_Expand().mt_Inpand() mt_MakeDiff(last, input) mt_Logic(last, aWarpsharp(depth=32), "min") lines = last mt_Expand() mt_Lut("x 130 - 255 140 130 - / *") mt_Merge(BlankClip(last, color=$808080), lines, last) mt_MakeDiff(input, last, U=2,V=2) Step 2: compact filterchain Target is the Levels().Overlay() combo. This [1'clip'filter]+[3'clip'filter] can be expressed by one single [2'clip'filter], which is obviously cheaper. Code:
input.mt_Expand().mt_Inpand() mt_MakeDiff(last, input) mt_Logic(aWarpsharp(depth=32), "min") mt_LutXY(mt_Expand(),"y 130 < 128 y 140 > x x y 130 - 255 140 130 - / * * 128 255 y 130 - 255 140 130 - / * - * + 255 / ? ?") mt_MakeDiff(input, last,U=2,V=2) Speed comparison: Used a tenfold "Toon().Toon().Toon...." combo, let render 500 frames, computed fps. Code:
Toon v0.81: ~2.1 fps (100%) Step 0.5. : ~2.85 fps (136%) Step 1 : ~4.7 fps (224%) Step 2 : ~4.9 fps (233%, and better rounding) Olé !
__________________
- 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!) |
6th July 2007, 16:22 | #10 | Link |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Code:
# Toon v0.82 # # Idea by mf # Speedups by Didee # # Req: MaskTools2, aWarpSharp function Toon(clip input) { input.mt_Expand().mt_Inpand() mt_MakeDiff(last, input) mt_Logic(aWarpSharp(depth=32), "min") mt_LutXY(mt_Expand(),"y 130 < 128 y 140 > x x y 130 - 255 140 130 - / * * 128 255 y 130 - 255 140 130 - / * - * + 255 / ? ?") mt_MakeDiff(input, last,U=2,V=2) } Last edited by Soulhunter; 25th October 2007 at 19:05. |
6th July 2007, 18:41 | #11 | Link |
Registered User
Join Date: Jun 2007
Posts: 33
|
Thanks Soulhunter & Didée!
Any instructions on how to change the parameters (strength, etc.)? FWIW - even though I think it does a great job, I couldn't take vmToon's slow speed anymore so I'm trying a combination of FastLineDarken(strength=32,thinning=0) followed by LimitedSharpenFaster (Smode=3 (default??)). I'll compare withToon v0.82 later today or tomorrow. Soulhunter - thanks for the smoother rec. I'm trying DCTFun4b(2,2) w/ VagueDenoiser instead of Deen. |
8th July 2007, 19:38 | #12 | Link |
Registered User
Join Date: Dec 2006
Posts: 280
|
Toon v0.82 darkens a bit too much for my taste, vmtoon 0.7x allowed me better control of that - which isn't there anymore in 0.82.
Another thing which I don't like in 0.82 is the asharp's settings, I'v tried varying 16 to 32, to make the line thinner, but it creates jaggy edges, my solution was to use warpsharp(not the awarpsharp) with 128, that gave me better results - though I am not sure what the speed difference of awarpsharp and warpsharp is... Anyway, thanks . |
9th July 2007, 07:35 | #13 | Link |
Registered User
Join Date: May 2005
Location: Germany
Posts: 495
|
@Soulhunter
Sorry for my late reaction. I tested the function and likes the idea. But yes, parameters are necessary: I modificated it to my needs: Code:
function toon(input, float "str", int "l_thr", int "u_thr", int "wdepth", int "wlevel") { sstr = string(default(str,1.0)) lthr = string(128+default(l_thr,2)) uthr = string(128+default(u_thr,12)) ludiff = string(default(u_thr,12)-default(l_thr,2)) wdepth = default(wdepth,32) wlevel = default(wlevel,2) input.mt_expand().mt_inpand().mt_makediff(input) mt_logic(last,last.aWarpsharp(depth=wdepth,blurlevel=wlevel,cm=0), "min") mt_lutxy(last,last.mt_expand(),"y "+lthr+" <= 128 y "+uthr+" >= x "+uthr+" y - 128 * x y "+lthr+" - * + "+ludiff+" / ? 128 - "+sstr+" * 128 + ?") return mt_makediff(input,last,U=2,V=2) } str - strength (default: 1.0) l_thr - lower thresh (default: 2) u_thr - upper thresh (default: 12) wdepth - warpdepth (default: 32) wlevel - warplevel (default: 2) With default settings it gives the same output as Didee´s speedup version. @DarkT Maybe it helps if to set the blurlevel=1. As far as I know warpsharp is a good amount slower than awarpsharp. Last edited by MOmonster; 9th July 2007 at 07:39. |
10th July 2007, 11:38 | #15 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
They're parameters for the edit that momonster just posted, not the original.
Warpsharp is definitely slower, almost one third of the speed. Last edited by foxyshadis; 10th July 2007 at 12:29. |
11th July 2007, 10:56 | #16 | Link |
Registered User
Join Date: May 2005
Location: Germany
Posts: 495
|
If toon is still not fast enough, what about this:
Code:
############### ## Toon v0.82 edit ## ############### # function created by mf # support by Soulhunter ;-) # ported to masktools v2 and optimized by Didee (0.82) # added parameters and smaller changes by MOmonster (0.82 edited) # toon v0.8 is the newest light-weight build of mf´s nice line darken function mf_toon # # needed filters: # - MaskTools v2 # - AWarpSharp # # parameters: # str - strength of the line darken 1.0 # l_thr - lower threshold for the linemask 2 # u_thr - upper threshold for the linemask 12 # wdepth - warping depth (awarpsharp readme) 32 # wlevel - warping level (awarpsharp readme) 2 (1 is faster) # fast - gives better speed with only a little # difference to the default output false function toon(input, float "str", int "l_thr", int "u_thr", int "wdepth", int "wlevel", bool "fast") { sstr = string(default(str,1.0)) lthr = string(128+default(l_thr,2)) uthr = string(128+default(u_thr,12)) ludiff = string(default(u_thr,12)-default(l_thr,2)) wdepth = default(wdepth,32) wlevel = default(wlevel,2) fast = default(fast,false) input.mt_expand().mt_inpand().mt_makediff(input) mt_logic(last,last.aWarpsharp(depth=wdepth,blurlevel=wlevel,cm=0), "min") fast==true ? mt_lut("x "+lthr+" <= 128 x "+uthr+" >= x "+uthr+" x - 128 * x x "+lthr+" - * + "+ludiff+" / ? 128 - "+sstr+" * 128 + ?") : mt_lutxy(last,last.mt_expand(),"y "+lthr+" <= 128 y "+uthr+" >= x "+uthr+" y - 128 * x y "+lthr+" - * + "+ludiff+" / ? 128 - "+sstr+" * 128 + ?") return mt_makediff(input,last,U=2,V=2) } As foxyshadis said, they are parameters of my edit, but of course the edit works the same way as the original (that has no parameters), there are no other filter-calls than in Didee's version. |
11th July 2007, 15:28 | #18 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Yes.
__________________
- 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!) |
11th July 2007, 16:51 | #19 | Link |
warpsharpened
Join Date: Feb 2007
Posts: 787
|
How does it compare to FastLineDarkenMOD in both quality and speed?
Since I've found fast line darken (mod) it's the only thing I've ever used for line darkening since it's faster then anything I've found. Since no one really ever used the sharpening part of vmtoon anyway I use this: Code:
FastLineDarkenMOD(thinning=0, strength=60) Code:
############################# # FastLineDarken 1.3 MT MOD # ############################# # # Written by Vectrangle, last update 12 Sept 04 # # * requires mt_masktools v2 # * requires yv12 input # # Usage is FastLineDarken(strength, luma_cap, threshold, thinning), # named parameters are supported eg FastLineDarken(thinning=0) # # Note that you must import this avs into your script using import("...\FastLineDarken.avs") # # Parameters are: # strength (integer) - Line darkening amount, 0-256. Default 48. Represents the _maximum_ amount # that the luma will be reduced by, weaker lines will be reduced by # proportionately less. # luma_cap (integer) - value from 0 (black) to 255 (white), used to stop the darkening # determination from being 'blinded' by bright pixels, and to stop grey # lines on white backgrounds being darkened. Any pixels brighter than # luma_cap are treated as only being as bright as luma_cap. Lowering # luma_cap tends to reduce line darkening. 255 disables capping. Default 191. # threshold (integer) - any pixels that were going to be darkened by an amount less than # threshold will not be touched. setting this to 0 will disable it, setting # it to 4 (default) is recommended, since often a lot of random pixels are # marked for very slight darkening and a threshold of about 4 should fix # them. Note if you set threshold too high, some lines will not be darkened # thinning (integer) - optional line thinning amount, 0-256. Setting this to 0 will disable it, # which is gives a _big_ speed increase. Note that thinning the lines will # inherently darken the remaining pixels in each line a little. Default 24. # # Changelog: # 1.3 - added ability to thin lines, now runs much slower unless thinning=0. Changed the defaults (again) # 1.2 - huge speed increase using yv12lutxy =) # - weird darkening issues gone (they were caused by yv12layer) # - show option no longer available due to optimizations. Use subtract() instead # 1.1 - added luma_cap option # 1.0 - initial release # function FastLineDarkenMOD( clip c, int "strength", int "luma_cap", int "threshold", int "thinning") { ## parameters ## str = string(default(strength, 48) /128.) lum = string(default(luma_cap, 191)) thr = string(default(threshold, 4)) thinning = default(thinning,24) thn = string(thinning /16.) ## filtering ## exin = c.mt_expand().mt_inpand() diff = mt_lutxy(c,exin,yexpr="y "+lum+" < y "+lum+" ? x "+thr+" + > x y "+lum+" < y "+lum+" ? - 0 ? 127 +",uexpr="x",vexpr="x",u=2, v=2) linemask= mt_lut(diff.mt_inpand(),"x 127 - "+thn+" * 255 +").mt_convolution("1 1 1","1 1 1",y=3,u=0,v=0) thick = mt_lutxy(c, exin, yexpr="y "+lum+" < y "+lum+" ? x "+thr+" + > x y "+lum+" < y "+lum+" ? - 0 ? "+str+" * x +",uexpr="x",vexpr="x",u=2, v=2) thin = mt_lutxy(c.mt_expand(),diff,yexpr="x y 127 - "+str+" 1 + * +",u=2, v=2) return (thinning == 0) ? thick : mt_merge(thin,thick,linemask,y=3,u=2,v=2) } Last edited by TheRyuu; 11th July 2007 at 16:55. |
11th July 2007, 17:14 | #20 | Link |
*Space Reserved*
Join Date: May 2006
Posts: 953
|
Yes, that was the script I posted, here's an updated version that's a bit faster thanks to King Didée
Code:
############################## # FastLineDarken 1.3x MT MOD # ############################## # # Written by Vectrangle # Didée: - Speed Boost, Updated: 11th May 2007 # # * requires masktools 1.5.1 -- http://jourdan.madism.org/~manao/ # * requires yv12 input # # Usage is FastLineDarken(strength, luma_cap, threshold, thinning), # named parameters are supported eg FastLineDarken(thinning=0) # # Note that you must import this avs into your script using import("...\FastLineDarken.avs") # # Parameters are: # strength (integer) - Line darkening amount, 0-256. Default 48. Represents the _maximum_ amount # that the luma will be reduced by, weaker lines will be reduced by # proportionately less. # luma_cap (integer) - value from 0 (black) to 255 (white), used to stop the darkening # determination from being 'blinded' by bright pixels, and to stop grey # lines on white backgrounds being darkened. Any pixels brighter than # luma_cap are treated as only being as bright as luma_cap. Lowering # luma_cap tends to reduce line darkening. 255 disables capping. Default 191. # threshold (integer) - any pixels that were going to be darkened by an amount less than # threshold will not be touched. setting this to 0 will disable it, setting # it to 4 (default) is recommended, since often a lot of random pixels are # marked for very slight darkening and a threshold of about 4 should fix # them. Note if you set threshold too high, some lines will not be darkened # thinning (integer) - optional line thinning amount, 0-256. Setting this to 0 will disable it, # which is gives a _big_ speed increase. Note that thinning the lines will # inherently darken the remaining pixels in each line a little. Default 24. # # Changelog: # 1.3 - added ability to thin lines, now runs much slower unless thinning=0. Changed the defaults (again) # 1.2 - huge speed increase using yv12lutxy =) # - weird darkening issues gone (they were caused by yv12layer) # - show option no longer available due to optimizations. Use subtract() instead # 1.1 - added luma_cap option # 1.0 - initial release # function FastLineDarkenMOD( clip c, int "strength", int "luma_cap", int "threshold", int "thinning") { ## parameters ## str = string(default(strength, 48) /128.) lum = string(default(luma_cap, 191)) thr = string(default(threshold, 4)) thinning = default(thinning,24) thn = string(thinning /16.) ## filtering ## exin = c.mt_expand().mt_inpand() diff = mt_lutxy(c,exin,yexpr="y "+lum+" < y "+lum+" ? x "+thr+" + > x y "+lum+" < y "+lum+" ? - 0 ? 127 +",uexpr="x",vexpr="x",u=2, v=2) linemask= mt_lut(diff.mt_inpand(),"x 127 - "+thn+" * 255 +").RemoveGrain(20,-1) thick = mt_lutxy(c, exin, yexpr="y "+lum+" < y "+lum+" ? x "+thr+" + > x y "+lum+" < y "+lum+" ? - 0 ? "+str+" * x +",uexpr="x",vexpr="x",u=2, v=2) thin = mt_lutxy(c.mt_expand(),diff,yexpr="x y 127 - "+str+" 1 + * +",u=2, v=2) return (thinning == 0) ? thick : mt_merge(thin,thick,linemask,y=3,u=2,v=2) } |
Thread Tools | Search this Thread |
Display Modes | |
|
|