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. |
28th April 2003, 19:27 | #1 | Link |
·
Join Date: Jan 2002
Posts: 1,729
|
experimental fxToon replacement: mfToon
After much research in Paint Shop Pro and VirtualDub, I am happy to annouce an experimental rudimentary version of mfToon!
What's it do: It darkens lines in anime! ^_^ What's the catch: It SLIGHTLY darkens non-lines. What's the speed: 10fps @ 640x480 on an Athlon XP 2000+ Where can I get it: HERE! Code:
orig = AVISource("in.avi") mask = orig.Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58) sharp = Subtract(orig, mask).ConvertToYUY2() origyuy = orig.ConvertToYUY2() sharp2 = origyuy.MergeLuma(Layer(origyuy, sharp, "mul", 255) \ .Levels(0, 1.0, 115, 0, 255)).ConvertToRGB32() origrgb = origyuy.ConvertToRGB32() greymask = origrgb.Greyscale().Levels(0, 1, 255, 255, 0) maskedsharp = Mask(sharp2, greymask) final = Layer(origrgb, maskedsharp, "add", 255) return final Code:
orig = AVISource("in.avi").Convolution3D(preset="AnimeLQ") mask = orig.Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58) sharp = Subtract(orig, mask).ConvertToYUY2() origyuy = orig.ConvertToYUY2() sharp2 = origyuy.MergeLuma(Layer(origyuy, sharp, "mul", 255) \ .Levels(0, 1.0, 115, 0, 255)).ConvertToRGB32() origrgb = origyuy.ConvertToRGB32() greymask = origrgb.Greyscale().Levels(0, 1, 255, 255, 0) maskedsharp = Mask(sharp2, greymask) semifinal = Layer(origrgb, maskedsharp, "add", 255).ConvertToYUY2().ConvertToYV12(). \ BicubicResize(1920, 1440, 0, 0.75) \ .XSharpen(255, 255).BilinearResize(640, 480).WarpSharp(15, 5) final = orig.MergeLuma(semifinal) return final I'll keep you updated on progress . Edit: Here's a screenshot (left processed, right original): http://mf.onthanet.com/linedarkening/practice-1.png Oh and btw, when it's finished it should look something like this: http://mf.onthanet.com/linedarkening/theory-4.png http://mf.onthanet.com/linedarkening...4_original.png (I cooked this up in PSP + Vdub) Edit 2: mods: DON'T edit scripts without verifying if your wrappers actually work. Edited so they work. Last edited by mf; 28th April 2003 at 20:37. |
28th April 2003, 20:35 | #3 | Link |
another encoding dude..^^
Join Date: Mar 2002
Posts: 100
|
good job there ... even though it darkens the video abit .. the quality is still much better .... :P
EDIT : this filter-chain amplify noise as well ... use with care ...
__________________
-- SunG -- " The more knowledge you give, the more knowledge you gain. Its different from wealth. " Last edited by sungey; 29th April 2003 at 04:16. |
28th April 2003, 21:57 | #4 | Link | |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Re: experimental fxToon replacement: mfToon
Quote:
|
|
28th April 2003, 21:59 | #5 | Link | |
·
Join Date: Jan 2002
Posts: 1,729
|
Re: Re: experimental fxToon replacement: mfToon
Quote:
My point was that keeping a script functional is more important than wether it fits on the page or not. Last edited by mf; 28th April 2003 at 23:43. |
|
29th April 2003, 14:53 | #6 | Link |
Registered User
Join Date: Jun 2002
Location: Somewhere you don't ever want to be
Posts: 78
|
I don't know what you did to the theory picture (not the original) as far as filtering, but it looks as if the lines have been thined, and don't look any darker, also, due to their being thinned, the jagged edges on those lines are more pronounced, as if you had used warpsharp on it. However the practice.png looks well done. I'll be sure to test this when I get home.
|
29th April 2003, 15:02 | #7 | Link | |
·
Join Date: Jan 2002
Posts: 1,729
|
Quote:
|
|
29th April 2003, 15:31 | #8 | Link |
Registered User
Join Date: Jun 2002
Location: Somewhere you don't ever want to be
Posts: 78
|
pardon me for going off topic for just a moment, but since you brought it up, supersampling, I've only ever heard of it being used to offset an odd effect of xsharpen, is there merit in supersampling, and where can I find out more about it and its merit for certain filters/types of filters (anywhere besides the holy "search" button).
In any case, I've seen your discussions with neuron2 about your unshrap mask experiments and the script you've provided here looks to have some of the same elements. Never having experience with unsharp mask filters either in a photoediting program (PSP, PhotoShop, etc) or vdub's version, would it be possible to explain what an unsharp mask does, perhaps as opposed to a standard sharpener? Or must I go on the quest for the holy readme.txt? It would make my testing job for your script=mftoon if I know what it is I'm looking for besides thicker/darker lines. |
29th April 2003, 17:07 | #9 | Link |
·
Join Date: Jan 2002
Posts: 1,729
|
The explanation is simple. Unsharp mask makes adjacent dark image elements darker, and light elements lighter. I use a brighness mask to eliminate the lightening effect. That means when a dark image element is next to a lighter one, it will get darkened. This is a very simple way to darken lines. That's the basic concept. Now to refine, I sharpen with supersampled xsharpen. What that does, is I use bicubic interpolation to "make up" curves that aren't there. XSharpen sharpens those so far that they become "jagged edges", or aliased. Downsizing back to the original size will cause the jagged edges to be averaged along the made up curves, causing a sharp anti-alias effect. A side effect of the line darkening, is that it seems to thicken the lines, because blurry lines are wider than sharp ones. So I use Warp Sharp to thin those lines. I overlay the xsharpened image over the warp sharpened image with again a brightness mask, so that only the dark lines will be replaced by the warp sharped thinner lines (I'm still wrestling with that in AVISynth, which seems to be a lot harder to do than in Paint Shop Pro). Warp Sharp has a nasty side effect of causing slight (not as bad as xsharpen) jagging when used with higher strengths (as needed for effective line thinnign), so I supersample 2x2 (meaning 2 times the original size) to compensate for that. Hope this explains everything good enough .
|
29th April 2003, 21:01 | #12 | Link |
Registered User
Join Date: Jun 2002
Location: Somewhere you don't ever want to be
Posts: 78
|
I'm accustomed to the wonders of the sub 4fps myself, speed's not an issue where a challange is concerned, so if you're to share I'd love to see it. ^_^
Thank you very much for the explanation of the unsharp mask and supersampling you've done, it's made this all much easier for me to understand. I hope I'll be able to contribute something meaningful to its developement through some of my test encodes. |
29th April 2003, 21:13 | #13 | Link |
·
Join Date: Jan 2002
Posts: 1,729
|
Ok, here goes ~_~ *closes eyes as if he's on a rollercoaster that's climbing up*
For sharp anime (Narue no Sekai, Wolf's Rain, etc) Code:
orig = AVISource("in.avi").Convolution3D(preset="AnimeLQ") mask = orig.Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58) sharp = Subtract(orig, mask).ConvertToYUY2() origyuy = orig.ConvertToYUY2() sharp2 = origyuy.MergeLuma(Layer(origyuy, sharp, "mul", 255) \ .Levels(0, 1.0, 80, 0, 255)).ConvertToRGB32().MSmooth() origrgb = origyuy.ConvertToRGB32() greymask = origrgb.Greyscale().Levels(0, 0.6, 175, 255, 0) maskedsharp = Mask(sharp2, greymask) ssxsh = Layer(origrgb, maskedsharp, "add", 255).ConvertToYUY2().ConvertToYV12() \ .BicubicResize(1920, 1440, 0, 0.75).XSharpen(255, 255) warpsharp = ssxsh.BilinearResize(640, 480).BicubicResize(1280, 1024, 0, 0.75) \ .aWarpSharp(56, 2, 0.5, 0).BicubicResize(1920, 1440, 0, 0.75).ConvertToRGB32() ssxshrgb = ssxsh.ConvertToRGB32() darknessmask = ssxshrgb.Greyscale() detailmask = orig.MSmooth().EdgeMask(0, "sobel").GreyScale() \ .BicubicResize(1920, 1440, 0, 0.75).ConvertToRGB32() white = BlankClip(darknessmask, color=$FFFFFF) maskeddarkness = Mask(detailmask, darknessmask) warpmask = Layer(white, maskeddarkness, "add", 255).Levels(0, 1, 255, 255, 0) \ .Levels(30, 1.0, 60, 0, 255).ConvertToYUY2.ConvertToYV12().Levels(0, 1, 255, 255, 0) \ .Inflate().Levels(0, 1, 255, 255, 0).ConvertToRGB32().GreyScale() maskedssxsh = Mask(ssxshrgb, warpmask) semifinal = Layer(warpsharp, maskedssxsh, "add", 255).ConvertToYUY2().ConvertToYV12() \ .BilinearResize(640, 480) final = orig.MergeLuma(semifinal) return final Here's a screenshot: http://mf.onthanet.com/linedarkening/practice-2.png And now for blurry anime (Naruto, Naruto, Naruto, etc) Code:
orig = AVISource("in.avi").Convolution3D(preset="AnimeLQ") mask = orig.Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58) sharp = Subtract(orig, mask).ConvertToYUY2() origyuy = orig.ConvertToYUY2() sharp1 = origyuy.MergeLuma(Layer(origyuy, sharp, "mul", 255) \ .Levels(0, 1.0, 80, 0, 255)) sharp2 = origyuy.MergeLuma(Layer(sharp1, sharp, "mul", 128) \ .Levels(0, 1.0, 180, 0, 255)).ConvertToRGB32().MSmooth() origrgb = origyuy.ConvertToRGB32() greymask = origrgb.Greyscale().Levels(0, 0.6, 175, 255, 0) maskedsharp = Mask(sharp2, greymask) ssxsh = Layer(origrgb, maskedsharp, "add", 255).ConvertToYUY2().ConvertToYV12() \ .BicubicResize(1920, 1440, 0, 0.75).XSharpen(255, 255) warpsharp = ssxsh.BilinearResize(640, 480).BicubicResize(1280, 1024, 0, 0.75) \ .aWarpSharp(56, 2, 0.5, 0).BicubicResize(1920, 1440, 0, 0.75).ConvertToRGB32() ssxshrgb = ssxsh.ConvertToRGB32() darknessmask = ssxshrgb.Greyscale() detailmask = orig.MSmooth().EdgeMask(0, "sobel").GreyScale() \ .BicubicResize(1920, 1440, 0, 0.75).ConvertToRGB32() white = BlankClip(darknessmask, color=$FFFFFF) maskeddarkness = Mask(detailmask, darknessmask) warpmask = Layer(white, maskeddarkness, "add", 255).Levels(0, 1, 255, 255, 0) \ .Levels(30, 1.0, 60, 0, 255).ConvertToYUY2.ConvertToYV12() \ .Levels(0, 1, 255, 255, 0) \ .Inflate().Levels(0, 1, 255, 255, 0).ConvertToRGB32().GreyScale() maskedssxsh = Mask(ssxshrgb, warpmask) semifinal = Layer(warpsharp, maskedssxsh, "add", 255).ConvertToYUY2().ConvertToYV12() \ .BilinearResize(640, 480) final = orig.MergeLuma(semifinal) return final http://mf.onthanet.com/linedarkening/practice-3.png You need MSmooth, Conv3DYV12, WarpSharp, aWarpSharp, and MaskTools. Because of my bad scripting I will now set up a disclaimer. By replying to this post you agree that you will not criticize my HORRIBLE script unless you have a good suggestion on how to do it better. I know this is crappy and slow, that's why it's experimental. I'm just afraid of breaking it when I optimize it for speed ~_~. Happy 1fps encoding! -_-;; Oh yeah, and a note to supreme post-edit-master neuron, I will edit my post and add wrappers in a sec. Edit: Edited them :>. Last edited by mf; 29th April 2003 at 21:56. |
29th April 2003, 21:52 | #14 | Link |
Registered User
Join Date: May 2002
Posts: 384
|
the scirpt isnt working for me. I keep on getting Invalid arguments to Convolution3d, even though it should work (no typos). Also Xsharpen isnt recognised either. I do have all filters needed in my autoload folder including latest warpsharp package.
ps The awarpsharp link leads to the asharp.dll. Kep up the good work! ^^ |
29th April 2003, 22:04 | #15 | Link | |
·
Join Date: Jan 2002
Posts: 1,729
|
Quote:
|
|
29th April 2003, 22:29 | #16 | Link | |
Registered User
Join Date: May 2002
Posts: 384
|
Quote:
Last edited by Dreassica; 29th April 2003 at 22:42. |
|
29th April 2003, 22:46 | #17 | Link |
Registered User
Join Date: Jun 2002
Location: Somewhere you don't ever want to be
Posts: 78
|
I've run several tests now (I forgot how much fun it was to spend 30 minutes encoding a minute and a half of footage XD hehe) and the results are very encouraging. The lines show a noticable darkness though some elements look to be a little jagged. There is definately room for tweaking and, admitadly, speed optimization, but an altogether excellent work mf, thanks for the trouble, I'm sure this'll keep my nose in the encodes for another few weeks with tests
|
30th April 2003, 10:23 | #19 | Link | |
·
Join Date: Jan 2002
Posts: 1,729
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|