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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th April 2003, 19:27   #1  |  Link
mf
 
mf's Avatar
 
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
Yes this is a mess, yes this could probably be done much better. No I don't care. This is just experimental and rudimentary, so don't complain . I'll get this done better soon. If you want even more quality (and even less speed), try this:
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
You'll need the PROPER (not the one on the avisynth beta page) WarpSharp.dll. You can get it here.

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.
mf is offline   Reply With Quote
Old 28th April 2003, 20:10   #2  |  Link
digitize
Registered User
 
digitize's Avatar
 
Join Date: Aug 2002
Posts: 142
/me bows down to mf..... im not worthy
great job mf, you have discovered the holy grail of anime encoding for avs ... im going off to test it now.
digitize is offline   Reply With Quote
Old 28th April 2003, 20:35   #3  |  Link
sungey
another encoding dude..^^
 
sungey's Avatar
 
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.
sungey is offline   Reply With Quote
Old 28th April 2003, 21:57   #4  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,923
Re: experimental fxToon replacement: mfToon

Quote:
Originally posted by mf
Edit 2: mods: DON'T edit scripts without verifying if your wrappers actually work. Edited so they work.
Please DON'T post long code lines that cause the page to get too wide. Then the mod won't have to intervene. Thank you.
Guest is offline   Reply With Quote
Old 28th April 2003, 21:59   #5  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Re: Re: experimental fxToon replacement: mfToon

Quote:
Originally posted by neuron2
Please DON'T post long code lines that cause the page to get too wide. Then the mod won't have to intervene. Thank you.
When I'm busy trying things out, I tend to forget cosmetic things like that. Sorry. (I'm running 1280x960 res, so I don't notice)
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.
mf is offline   Reply With Quote
Old 29th April 2003, 14:53   #6  |  Link
WyldeF1r3
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.
WyldeF1r3 is offline   Reply With Quote
Old 29th April 2003, 15:02   #7  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Quote:
Originally posted by WyldeF1r3
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.
Bingo. I warpsharped it as far as it would still look good when played fullscreen. And don't get me wrong, I warp sharped supersampled.
mf is offline   Reply With Quote
Old 29th April 2003, 15:31   #8  |  Link
WyldeF1r3
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.
WyldeF1r3 is offline   Reply With Quote
Old 29th April 2003, 17:07   #9  |  Link
mf
 
mf's Avatar
 
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 .
mf is offline   Reply With Quote
Old 29th April 2003, 20:42   #10  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Ok, I just managed to make something that really looks nice on naruto, but it's such a mess I don't dare post it here . And it's badass slow too. I'll hear it if someone really wants it .
mf is offline   Reply With Quote
Old 29th April 2003, 20:46   #11  |  Link
Dreassica
Registered User
 
Join Date: May 2002
Posts: 384
slow or not, me wants it. So do not hesitate to share it .
Dreassica is offline   Reply With Quote
Old 29th April 2003, 21:01   #12  |  Link
WyldeF1r3
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.
WyldeF1r3 is offline   Reply With Quote
Old 29th April 2003, 21:13   #13  |  Link
mf
 
mf's Avatar
 
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
Screenshot of this one:
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.
mf is offline   Reply With Quote
Old 29th April 2003, 21:52   #14  |  Link
Dreassica
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! ^^
Dreassica is offline   Reply With Quote
Old 29th April 2003, 22:04   #15  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Quote:
Originally posted by Dreassica
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! ^^
I always load everything manually. Just to be sure . The warpsharp you need is different though (as I said at the top of the thread), so you should make sure you have the same version as me. It includes a proper XSharpen. I updated the link, and thanks for the compliment ! Also note that I edited my post and added screenshots. So if it's still not working you can see the effect anyway .
mf is offline   Reply With Quote
Old 29th April 2003, 22:29   #16  |  Link
Dreassica
Registered User
 
Join Date: May 2002
Posts: 384
Quote:
Originally posted by mf
I always load everything manually. Just to be sure . The warpsharp you need is different though (as I said at the top of the thread), so you should make sure you have the same version as me. It includes a proper XSharpen. I updated the link, and thanks for the compliment ! Also note that I edited my post and added screenshots. So if it's still not working you can see the effect anyway .
i downloaded that warpsharp package from the link u gave, so that cant be it.

Last edited by Dreassica; 29th April 2003 at 22:42.
Dreassica is offline   Reply With Quote
Old 29th April 2003, 22:46   #17  |  Link
WyldeF1r3
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
WyldeF1r3 is offline   Reply With Quote
Old 30th April 2003, 06:21   #18  |  Link
jarthel
plebian
 
Join Date: Nov 2001
Posts: 775
Can these be used in .d2v files? The samples uses .avi.

Thanks

Jayel
jarthel is offline   Reply With Quote
Old 30th April 2003, 10:23   #19  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Quote:
Originally posted by jarthel
Can these be used in .d2v files? The samples uses .avi.

Thanks

Jayel
Of course it can, but you'll have to modify it yourself. Because it's experimental, it'll only do AVI at 640x480 unless you modify it.
mf is offline   Reply With Quote
Old 30th April 2003, 12:00   #20  |  Link
jarthel
plebian
 
Join Date: Nov 2001
Posts: 775
It shouldn't be a problem them. I always use 640x480 as my output resolution.

I'll try it overnight. Thanks

Jayel
jarthel is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.