SuperToon

From Avisynth wiki
Jump to: navigation, search
Abstract
Author Hadien
Version 11/02/2012
Download SuperToon script
Category Line Darkeners
License
Discussion Doom9 Thread

Contents

Description

SuperToon is an attempt to optimize/speed up the previous versions of mfToon, vmToon, etc.

Requirements

  • AviSynth 2.5.8 or greater
  • Supported color formats: YV12

Required Plugins

Latest versions of the following filters are recommended unless stated otherwise.


Syntax and Parameters

SuperToon (clip input, float "power", int "mode", int "Nthr", int "Nstr", int "Ncap", int "Lthr", int "Hthr", int "Lcap", int "cont", bool "show")


clip   =
Input clip.


float  power = .75
Values -255.0-255. 0 will have impact however a range from 0.2-1.5 is usually the desired range. Positive values darken lines, negative values brighten them. 0 won't sharpen the video however SuperToon will still consume CPU. When setting the Nthr, NCap, Lcap, and pretty much any other setting, you can set this to an extreme value like 100, this way you can easily see (as if the edge mask was overlayed on the original) what SuperToon will be darkening (whether it'd be the lines you want it to darken or the noise you didn't want it you detect) for mode = 3, Power works differently. It ranges from -100 to 100 and its no longer the "strength of darkening" but instead the "strength of smoothing + sharpening"


int  mode = 0
Ranges from 0-4; tells SuperToon to try different methods no mode is always better than the other, its just that one mode can fare better for one source and not another. So the user has the option of which mode is best for their source. If you choose a number outside of the range it will default to 0.
  • mode=0: just applies a very simple edge detection mask with no effective noise detection.
  • mode=1: creates an edge mask and filters out noise by finding the average of all neighboring pixels and determines if the current pixel is an "outlier" and not noise, meaning its an edge to darken.
  • mode=2: similar to mode 1 but does things differently, it runs a sieve on all the neighboring pixels and then resets the edge mask to be the median of the results from that sieve. This method is a lot slower than the others, but sometimes its the only one that can seem to pull it off that the others can't.
  • mode=3: does things completely differently in that it performs a "filtered" UnFilter on the source. By filtered I mean it sharpens the lines while smoothing everything else. Very effective at removing noise and thinning lines, and is very fast. its just not as "strong" at sharpening as I had hoped as the other modes.
  • mode =4: works to ignore non-edge lines like shadow lines so it doesn't darken lines that weren't meant to be darkened. If you're getting something like black outlines around stars or snow, this mode is very good at preventing that. This mode doesn't run realtime for me (~20 fps for a 2.01 GHz single core).


int  Nthr = 4
Threshold to try to detect noise around the lines to be sharpened set this too high and it'll begin to confuse the lines you want sharpened as noise. This parameter works differently depending on the mode so certain in modes it works better in certain ranges. In nearly all modes its used to clip lower values from the generated mask (as noise). For modes 1 and 2 it used more to clean the noise from the lines. for 3 its used to filter between smoothing or sharpening. For mode 4 its used to overlay mode 0's mask onto mode 4's mask. Lower numbers add more weight to Mode 0's mask.


int  Nstr = 0
Can range from -100 to 100. 0 will make this do nothing. This is usually used to blur the edgemask to try to smooth out residual noise. Basically its a parameter that uses UnFilter() on the treated mask. Negative values work great for reducing noise, its fast and effective but values near the limits can demolish lines or produce a small halo effect. Positive values can help thin some lines which works great if the source doesn't present a lot of noise.


int  Ncap = 30
Ranges from 0 to 255, increasing it is the best (as far as filter speed) at preventing noise from being sharpened, however setting it too high and you won't be darkening any lines, this setting helps determine how "sensitive" it should be when looking at the edge mask. If it looks like the entire picture is darker, then its likely this value it too low. 18 is a good starting point for most sources I've tried.


int  Lthr = 0
Can range from 0-255, raising this value makes darkened lines thicker and helps with edge detection, but it'll usually give very very thick lines if you set this too high. 9 times out of 10 you will likely not have to change this from the default.


int  Hthr = 255
Can range from 0-255, lowering of this value has a stronger impact on line detection than the low threshold. Most of the time the default is the best setting.


int  Lcap = 255
Brightness cap which tells the function to only darken pixels under a certain luma value this is mostly intended to give more control to modes 0-2. Mode 3 doesn't use it, and mode 4 shouldn't ever need it. Setting it to 255 basically disables this.


int  cont = 180
Pixels are darkened by an amount relative to their spatial luma change. Pixels with very low luma change (like noise) is darkened very very slightly. Pixels with large luma change (like a black line) are greatly darkened. While moderate change (like a shadowline) is partially darkened. This value controls the contrast of these changes. Lowering this values makes it so that both low luma and high luma changes are subtracted by near the same amount. If you lower this value "power" will have to be raised to show a visible difference when used with Ncap, its very effective at removing noise.


bool  show = false
Set to true if you want the edge mask returned instead of the sharpened result.


Examples

AviSource("Blah.avi")
SuperToon()


Changelog

Version      Date(D/M/Y)      Changes
11/02/2012 - Thanks to: mastrboy for suggestion to use RemoveGrain() instead of Undot() theProfileth for optimizations to use mode=3 Chikuzen for error checking Didée for suggestion for mode =4.
02/02/2012 - Initial release


External Links




Back to External Filters

Personal tools