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

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th October 2012, 06:24   #1  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
5 new interpolation kernels (via DitherTools)

They are made available through a simple function "firniture".

example usage:
Code:
firniture(720, 400, kernel="noalias4", gamma=false)
The different interpolation methods are selected via the kernel string. The available options are as follows.

"binomial5", "binomial7": A binomial windowed sinc filter with 5 or 7 taps. Should have the least ringing of any available interpolator, except perhaps "noaliasnoring4".

"maxflat5", "maxflat8": 5 or 8 tap interpolation that is maximally flat in the passband. In English, these filters have a sharp and relatively neutral look, but can have ringing and aliasing problems.

"noalias4": A 4 tap filter hand designed to be free of aliasing while having acceptable ringing and blurring characteristics. Not always a good choice, but sometimes very useful.

"noaliasnoring4": Derived from the "noalias4" kernel, but modified to have reduced ringing. Other attributes are slightly worse.

"wall7": A windowed sinc function intended to be an alternative to high-tap lanczos. [edit] removed because it wasn't actually any better.

taps: [edit] Thanks to Didée pointing out some oversights on my part (I threw the baby out with the bathwater when I found StrCmpi() to be 2.6 only) , this parameter is now mostly superfluous. It has been retained so that you can truncate the kernels to shorter taps then they would normally use

gamma: Set to true to turn on gamma correction for the y channel. Off by default.

Otherwise it may be used as any of avisynths internal resizing functions; However, due to the method in which dithertools utilizes custom coeficients, accuracy will decrease when resizing by more then a factor of two. Maximum accuracy is only technically achieved when resizing by an exact factor of two, either up or down. This is most likely to manifest when using the non-sinc derived kernels, but is not generally an issue.

Code:
function firniture(clip c, int width_, int height_, string "kernel", int "taps", bool "gamma")
{
	binomial5 = string("8 0 -589 0 11203 0 -93355 0 606836 1048576 606836 0 -93355 0 11203 0 -589 0 8")
	binomial7 = string("146 0 -20294 0 744006 0 -11528384 0 94148472 0 -487836876 0 2551884458 4294967296 2551884458 0 -487836876 0 94148472 0 -11528384 0 744006 0 -20294 0 146")

	maxflat5 = string("-259 1524 -487 -12192 17356 42672 -105427 -85344 559764 1048576 559764 -85344 -105427 42672 17356 -12192 -487 1524 -259")
	maxflat8 = string(" 2 -26  166 -573  912 412 1524 -589 -12192 17356 42672 -105427 -85344 606836 1048576 606836 -85344 -105427 42672 17356 -12192 -589 1524 412 912 -573 166 -26 2 ")

	noalias4 = string("-1 2 4 -6 -17 7 59 96 59 7 -17 -6 4 2 -1")
	noaliasnoring4 = string("-1 8  40  -114 -512 360  3245 5664 3245 360 -512 -114 40 8 -1")

	kernel_ = Default(kernel, "binomial7")
	taps = Default(taps, int(value(rightstr(kernel,1))))
	gamma = default(gamma, false) 

	in = c
	out = in.Dither_convert_8_to_16
	out = gamma ? out.Dither_y_gamma_to_linear : out
	out = out.Dither_resize16(width_, height_, 0, 0, 0, 0, kernel="impulse "+string(Eval(kernel_))+"", kovrspl=2, taps=taps)
	out = gamma ? out.Dither_y_linear_to_gamma : out
	out = out.DitherPost
	
return(out)
}

[edit] updated the no-alias kernels, removed wall7 (it wasn't useful).
[edit2] remembered to update the example usage so that it functions after the changes.

Last edited by *.mp4 guy; 10th December 2012 at 05:15.
*.mp4 guy is offline   Reply With Quote
Old 12th October 2012, 08:03   #2  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Code:
taps = int(value(rightstr(kernel,1)))
or did I miss something?
__________________
- 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!)
Didée is offline   Reply With Quote
Old 12th October 2012, 08:45   #3  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by *.mp4 guy View Post
taps: Unfortunately a simple method of setting this automatically based on the selected kernel eluded me
[...]
However, due to the method in which dithertools utilizes custom coeficients, accuracy will decrease when resizing by more then a factor of two.
I'll try to fix theses issues in the next Dither release.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 12th October 2012, 09:00   #4  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Quote:
Originally Posted by Didée View Post
Code:
taps = int(value(rightstr(kernel,1)))
or did I miss something?
No, I had the same idea (that is why the names are formatted that way), but iirc Avisynth 2.6 is required for rightstr, and it breaks some of my scipts. However, its nice to have the syntax presumably sorted out for when 2.6 becomes stable.

Quote:
Originally Posted by cretindesalpes View Post
I'll try to fix theses issues in the next Dither release.
It wasn't meant as a criticism, the way dithertools does things now is in no way defective. Doing things better as far as accuracy is concerned may be complicated, though theoretically polynomial or spline interpolation should be fine.
*.mp4 guy is offline   Reply With Quote
Old 12th October 2012, 09:32   #5  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Why should 2.5.8 not have rightstr() ?

a=rightstr("onetwothr33",1)
version().subtitle(string(a),y=32)

__________________
- 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!)
Didée is offline   Reply With Quote
Old 15th October 2012, 01:29   #6  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Thanks for the help, Didée. I've been in the middle of moving, so it may take me a while to address the issue (no internet at the new place yet). If there is any interest, I'll also try to get around to putting up some examples or something as well.
*.mp4 guy is offline   Reply With Quote
Old 19th October 2012, 05:49   #7  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
The first post has an updated version of firniture that no longer requires setting taps manually.

[edit] The "noalias4" kernel has been updated, and is now significantly sharper
Additionally, here is a sample of the lighthouse image interpolated 4X by the "noalias4" kernel. Compare it to this interpolation using the standard spline36 kernel.

Keep in mind that these kernels are intended to be used for downscaling, or relatively small resolution adjustments. The comparison is done on upscaling because it makes the differences much easier to see. As should be clear, the "noalias4" kernel has very very good alias suppression, but is not quite as sharp as other kernels.

Each of the provided kernels is intended to fill a niche for which there currently exists no satisfactory solution in Avisynth. Obviously, using a low aliasing kernel on a blurry source would be a bad idea, but its great for those times when your stuck with an over-sharp source that is tripping up normal downscalers (or format shifters, etc.).

Last edited by *.mp4 guy; 8th December 2012 at 06:40.
*.mp4 guy is offline   Reply With Quote
Old 8th September 2014, 17:42   #8  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,665
@*.mp4 guy

I think line 15 may contain a small typo. If I try firniture(540,540, kernel="binomial7") it works but if I use firniture(540,540) I get this error: Script error: Invalid arguments to function "rightstr".
Adding _ to kernel in line 15 solves it, is that what you intended?
Code:
taps = Default(taps, int(value(rightstr(kernel_,1))))

Last edited by Reel.Deel; 8th September 2014 at 19:22. Reason: spelled firniture wrong
Reel.Deel is offline   Reply With Quote
Old 8th September 2014, 19:16   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
It does not say on *.mp4.guy's profile when he was last about, so,

Kernel is an optional arg, and if omitted will be at that point in script, Undefined().

So, is probably what was intended (EDIT: "kernel_" was intended).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 8th September 2014 at 19:27.
StainlessS 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 05:44.


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