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.

 Doom9's Forum A different approach to truncated sinc filters
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 5th September 2018, 09:05 #1  |  Link Katie Boundary Registered User     Join Date: Jan 2015 Posts: 616 A different approach to truncated sinc filters AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps. This leaves filter shapes that need to be "normalized" because their integrals don't equal 1. But has anyone looked into truncating the filter at x-values that leave a filter shape with an integral of exactly 1? So |x| = 0.61320733549 1.55775636508 2.53778369874 3.52784055722 and so on? __________________ If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
5th September 2018, 10:50   #2  |  Link
wonkey_monkey
Formerly davidh*****

Join Date: Jan 2004
Posts: 1,878
Quote:
 AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps.
As opposed to what? A non-integer number?

Sinc is an infinite filter. It will never add up to 1 in all finite cases.

And it's not the integral you want to equal 1, it's the sum of the particular coefficients that get picked, and those depend on your sampling position.

Quote:
 So |x| = 0.61320733549 1.55775636508 2.53778369874 3.52784055722 and so on?
The more I read this the more I suspect you don't have any understanding of how interpolation filters work.

Then again maybe I'm still blocked for daring to question your brilliance last time, so if anyone who isn't on the Naughty List wants to quote this...
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 5th September 2018 at 14:10.

5th September 2018, 18:27   #3  |  Link
Katie Boundary
Registered User

Join Date: Jan 2015
Posts: 616
Quote:
 Originally Posted by davidhorman This message is hidden because davidhorman is on your ignore list.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.

 5th September 2018, 19:11 #4  |  Link TheFluff Excessively jovial fellow   Join Date: Jun 2004 Location: rude Posts: 1,094 I'm a bit confused by your terminology and I'm not a DSP guru, but as far as I understand it, if you want a sinc filter where the coeffs sum to exactly 1, you pretty much want Lanczos, because that's pretty much what Lanczos is. Getting the coeffs to sum to exactly 1 in a real implementation (of any resizer) with all its pesky numerical precision issues requires dithering them though, and even then there might still be a small residual error. See for example zimg's take on it. Last edited by TheFluff; 5th September 2018 at 19:15.
5th September 2018, 20:01   #5  |  Link
wonkey_monkey
Formerly davidh*****

Join Date: Jan 2004
Posts: 1,878
Quote:
 Originally Posted by Katie Boundary Thank you for your input.
If you must be condescending when someone does their best to answer your questions, you should really only do so when you know what you're talking about.

You don't.

Furthermore, most of your "contributions" to this forum seem to consist of little more than insulting other members and spurning their advice, always given in good faith. You're dragging this forum down with your childishness and it's both pathetic and pitiful.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 5th September 2018 at 20:08.

5th September 2018, 21:15   #6  |  Link
Katie Boundary
Registered User

Join Date: Jan 2015
Posts: 616
Quote:
 Originally Posted by TheFluff I'm a bit confused by your terminology and I'm not a DSP guru, but as far as I understand it, if you want a sinc filter where the coeffs sum to exactly 1, you pretty much want Lanczos, because that's pretty much what Lanczos is.
Lanczos is a windowed sinc filter. I'm referring to truncated sinc, where it just gets cut off abruptly instead of tapering. But you bring up an interesting tangent: In some tests that I ran last night on Desmos, I did notice that Lanczos filters had integrals of pretty damn close to 1 for any number of taps 2 or greater. I expect this to be true of other windowed sinc filters as well. Even at only one tap, the integral was about 0.9

Quote:
 Originally Posted by TheFluff See for example zimg's take on it.
That looks a lot like C code, but isn't C supposed to start with "#include <stdio.h>" and have a "main int" somewhere?
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.

5th September 2018, 23:42   #7  |  Link
TheFluff
Excessively jovial fellow

Join Date: Jun 2004
Location: rude
Posts: 1,094
As davidhorman mentioned (see below for the record), if you want the coeffs for a sinc filter to sum to exactly 1 then you need an infinitely large filter kernel, so the question in the OP is nonsensical. If you want the coeffs to sum to exactly 1 then you can't just leave some of them out (which is what you do by only considering a fixed number of taps - the mathematically pure sinc filter has an infinite number of taps). So, as I said, the way you solve this is to use a window function because infinitely large filter kernels are obviously not practical, and the best way to do that windowing that anyone has come up with is Lanczos, and that's the only answer I can give you other than "you can't do that".

Quote:
Originally Posted by davidhorman
Quote:
 AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps.
As opposed to what? A non-integer number?

Sinc is an infinite filter. It will never add up to 1 in all finite cases.

And it's not the integral you want to equal 1, it's the sum of the particular coefficients that get picked, and those depend on your sampling position.

Quote:
 So |x| = 0.61320733549 1.55775636508 2.53778369874 3.52784055722 and so on?
The more I read this the more I suspect you don't have any understanding of how interpolation filters work.

Then again maybe I'm still blocked for daring to question your brilliance last time, so if anyone who isn't on the Naughty List wants to quote this...

Last edited by TheFluff; 5th September 2018 at 23:46.

6th September 2018, 18:16   #8  |  Link
Katie Boundary
Registered User

Join Date: Jan 2015
Posts: 616
Quote:
 Originally Posted by TheFluff As davidhorman mentioned (see below for the record), if you want the coeffs...
I didn't say anything about coeffs. I said the integral.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.

6th September 2018, 20:00   #9  |  Link
wonkey_monkey
Formerly davidh*****

Join Date: Jan 2004
Posts: 1,878
Quote:
 I didn't say anything about coeffs. I said the integral.
Why? What significance does the integral have?

Pass this on if you would, Fluff
__________________
My AviSynth filters / I'm the Doctor

7th September 2018, 01:46   #10  |  Link
TheFluff
Excessively jovial fellow

Join Date: Jun 2004
Location: rude
Posts: 1,094
Quote:
 Originally Posted by Katie Boundary I didn't say anything about coeffs. I said the integral.
I don't understand what you mean. Perhaps you can elaborate on your line of reasoning?

Last edited by TheFluff; 7th September 2018 at 01:48.

8th September 2018, 23:52   #11  |  Link
FranceBB

Join Date: Nov 2013
Location: Germany
Posts: 735
Quote:
 Originally Posted by Katie Boundary That looks a lot like C code
Almost. It's C++. ^_^

Quote:
 Originally Posted by Katie Boundary but isn't C supposed to start with "#include "
There's no need to include standard input output unless you need to.
It already includes a bunch of things needed for the calculations it has to do:

Code:
```#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <stdexcept>
#include <vector>```
And... in the code linked by TheFluff, the rounding is done (lines 93-115) using double and then float, trying to minimize the error.
__________________
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP - LUT Collection

10th September 2018, 18:31   #12  |  Link
Katie Boundary
Registered User

Join Date: Jan 2015
Posts: 616
Quote:
 Originally Posted by TheFluff I don't understand what you mean. Perhaps you can elaborate on your line of reasoning?
Just wondering if there's anything particularly magical about filter shapes with an integral of exactly 1, and if so, what the implications are for truncated (NOT windowed) sinc filters.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.