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 Usage

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 23rd March 2013, 23:57   #1  |  Link
Registered User
mandarinka's Avatar
Join Date: Jan 2007
Posts: 739
Mrdaa() - nnedi3-based anti-aliasing function (slow, daa-inspired, mostly for anime)

I am using this antialiasing function for some time, so it occurred to me I might post it here in case somebody finds it useful.

As many other approaches, this Mrdaa() function is based around nnedi3's upscaling mode. For that reason, it is usable for sources which have aliasing that is a product of computer rendering, also called pixelisation. It is not very good for aliasing that is a result of interlacing - for that purpose, Daa (ideally using nnedi3) is better, though that function can cause harm unless you upscale height a bit prior to processing. Mrdaa doesn't need this kludge BTW, it won't work right if you do that actually. Use mrdaa() on native resolution of the video!

The filter only kills aliasing up to a certain strength. Beyond that, nnedi3rpow2 simply isn't effective enough, and you will likely need to do something similar to Daa instead.

The upside of Mrdaa() though is that based on my testing, it is very friendly to detail. I used it for filtering few computer anime, and I think it can be called almost harmless. Not to 100%-degree (no filters are perfect), but compared to some other anti-aliasing methods people sadly seem to use, it is an enormous difference. I don't think I ever saw it to do obvious damage. Even comparing still shots will only show faint detail damage.

Demonstration pics:

For a look at what this thing does, look here.

I made these screenshots in the native resolution so that you can see the effects without added upscaling. However, since the improvement is best perceived when zoomed (the video will after all be played back in fullscreen), I added one sample that shows the difference after spline36resize(width*2,height*2).


What it does:
After running nnedi3rpow2 and scaling back to the original resolution, the script uses contrasharpening that is basically copied over from Daa (hence name). It is tweakable, but the idea is to produce a level of sharpness that somewhat matches the (aliased) original. The option is called "resharpen" - default is 1.0, use float values higher than 0. Smaller values reduce amount of resharpening, which might make antialiasing a bit stronger, higher values resharpen more. If you set it above 7.5 though, it will fail, because of how blur() works. Heheh.

I'm not good at scripting, so I didn't make the nnedi3 parameters tweakable. The ones used in the basic version of the function were picked to slightly improve the quality in difficult parts and make it slower over default nnedi3 settings. I added a faster and slower versions under separate call names, namely "MrdaaHQ()" (slower) and "MrdaaLame()" which is faster with default nnedi3 settings.

TL;DR - mild, very detail friendly antialiasing filter for computer-rendered anime. It can be used to clean up pixelisation without ugly effects.

Here is the 'code' - just save it into a txt file, change the extension to .avsi and call it in your chain: Mrdaa() or Mrdaa(resharpen=1.0). Please excuse the hacky way it is made - I am not programmer/scripter of any kind.

#Based on Daa: Anti-aliasing with contra-sharpening by Didée, modded by Terranigma for nnedi and by thetoof for merge
function Mrdaa(clip c, float "resharpen") {
resharpen = Default(resharpen,1.0)
dbl   = c.nnedi3_rpow2(rfactor=2,cshift="spline36resize",fwidth=c.width,fheight=c.height,fapprox=7,pscrn=1,etype=1,nns=2,nsize=3,qual=1)
dblD = mt_makediff(c,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.blur(resharpen*0.2,MMX=false),U=3,V=3)
DD = shrpD.repair(dblD,13)
return dbl.mt_adddiff(DD,U=3,V=3) }
function MrdaaLame(clip c, float "resharpen") {
resharpen = Default(resharpen,1.0)
dbl   = c.nnedi3_rpow2(rfactor=2,cshift="spline36resize",fwidth=c.width,fheight=c.height)
dblD = mt_makediff(c,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.blur(resharpen*0.2),U=3,V=3)
DD = shrpD.repair(dblD,13)
return dbl.mt_adddiff(DD,U=3,V=3) }
function MrdaaHQ(clip c, float "resharpen") {
resharpen = Default(resharpen,1.0)
dbl   = c.nnedi3_rpow2(rfactor=2,cshift="spline36resize",fwidth=c.width,fheight=c.height,fapprox=7,pscrn=1,etype=1,nns=4,nsize=3,qual=2)
dblD = mt_makediff(c,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.blur(resharpen*0.2,MMX=false),U=3,V=3)
DD = shrpD.repair(dblD,13)
return dbl.mt_adddiff(DD,U=3,V=3) }
I hope somebody finds this useful & thanks for reading through this textwall.

Last edited by mandarinka; 24th March 2013 at 00:21.
mandarinka is offline   Reply With Quote

antialias, antialiasing, mrdaa, nnedi

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 19:39.

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