Recommended Kaiser alpha values for windowed Sinc resampling

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by anthony »

NicolasRobidoux wrote:@Anthony: If I understand correctly, what you are talking about is "exact area filtering".
...
Yes, I know I'm simplifying, and not quite dealing with the precise question. But my opinion is that this direction (exact area methods) is a back back back back burner.
yes the discrete sampling only seemed to be important when sigma became very small, and in resampling you do not get sigma smaller that 1/2. I don't think it is worth the effort.

It isn't even used a lot with convolve kernel generation! Though the kernel generator for 1-D Gaussian does make some effort. It takes 3 'samples' of the function to generate the discrete value for the kernel. Comments say this was 'how photoshop did it'. Still it causes major headaches and worries when I was creating Named Kernels. It is not done for 2-d Gaussian, DoG or the closely related LoG kernels.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by NicolasRobidoux »

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by NicolasRobidoux »

anthony wrote:...It takes 3 'samples' of the function to generate the discrete value for the kernel. Comments say this was 'how photoshop did it'. Still it causes major headaches and worries when I was creating Named Kernels. It is not done for 2-d Gaussian, DoG or the closely related LoG kernels.
Exact area anything is generally a pain in the neck: To do things right you need to use antiderivatives, making sure not to be bitten by round off when you subtract values at nearby points, or high accuracy quadratures.
I'm not saying it's impossible. Just something I'd only be willing to fix if something's really broken, because unless you're careful, you'll just make things worse than just pretending that the local integral is proportional to the point value at the center (a low accuracy quadrature, as it were).
I believe that there used to be a minor industry computing high accuracy approximations of gaussian blur with specific stencils and sigma, roughly equivalent to computing quadratures with Gaussian density functions ("measures").
I certainly don't want to go there now.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by fmw42 »

NicolasRobidoux wrote: Exact area anything is generally a pain in the neck: To do things right you need to use antiderivatives ...
Curious use of antiderivative rather than (indefinite) integral (integration)! Why?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by anthony »

NicolasRobidoux wrote:I_0 = 1 (see http://www.efunda.com/math/bessel/besselIKPlot.cfm.)

Okay -- removing normalization factor from Kaiser. --- Put Back again Kaiser as x=0 returns a value of 106!!!
The multiplier is not a normalization but a make zero value = 1.0 which is a more desirable result for a filter

What about the Psuedo-Code... Do I have it correct?
If so I'll implement it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by NicolasRobidoux »

fmw42 wrote:
NicolasRobidoux wrote: Exact area anything is generally a pain in the neck: To do things right you need to use antiderivatives ...
Curious use of antiderivative rather than (indefinite) integral (integration)! Why?
I'm not sure I understand the question: The two terms are informally considered to be synonyms: http://en.wikipedia.org/wiki/Antiderivative.
In practice, if you don't use quadratures, you'll find the integrals over short intervals or squares by evaluating antiderivatives. (Yes, I know there are complications if the integrand is a piecewise function, or is not continuous.)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by fmw42 »

Just curious why you used antiderivative rather than integral. I know they are synonymous. But I rarely hear the use of antiderivative. Is that a Canadian or mathematician thing?
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by NicolasRobidoux »

@Fred: I think (they're in boxes right now) that recent Calculus textbooks use both terms to emphasize the "unexpected" fact that antiderivatives allow one to compute indefinite and definite integrals (a.k.a. Fundamental Theorem of Calculus). Conceptually, antiderivatives are different than indefinite integrals. The "miracle" is that they are twins. It's a pedagogical thing: the word "antiderivative" helps students remember what they have to do: "undo differentiation". This being said, I taught with a Canadian textbook (popular in the US and somewhat popular in French speaking Europe, I believe), Stewart's.
Last edited by NicolasRobidoux on 2012-05-11T09:42:11-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by fmw42 »

It has certainly been a long time since I took calculus. I guess terminology changes. Of course I had learned of antiderivative, but we mostly used integral back then. In most of my physics classes (undergrad and grad), the term antiderivative was hardly used in favor of integral.

Any way, it was just a curiosity question.

Thanks.

Fred
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by NicolasRobidoux »

anthony wrote:
NicolasRobidoux wrote:I_0 = 1 (see http://www.efunda.com/math/bessel/besselIKPlot.cfm.)

Okay -- removing normalization factor from Kaiser. --- Put Back again Kaiser at x=0 returns a value of 106!!!
The multiplier is not a normalization but a make zero value = 1.0 which is a more desirable result for a filter

What about the Psuedo-Code... Do I have it correct?
If so I'll implement it.
Your pseudo-code is correct.
But I suck! Kaiser at zero is not I_0 at zero, it's I_0 at beta, which the plot makes clear runs away from 1 pretty fast. If you want plots that go through 1 at x=0, you need the normalization, which you had just right.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Recommended Kaiser alpha values for windowed Sinc resamp

Post by anthony »

NicolasRobidoux wrote:
anthony wrote: Is this Pseudo-code correct?

Code: Select all

    beta=6.5
    if "filter:beta" then  beta=value
    if "filter:alpha" then  beta=value*PI
    normalization=1/IO(beta)
Then Kaiser formula as before. but using beta instead of alpha

Code: Select all

   normalization   *   IO(beta*sqrt(1.0-x*x))
Yes, this is correct. But please send me an email when you make that change, because then I'll need to change immediately what Adam runs (since right now we use an alpha value which should be set as a beta value once you've change this bit of the API).
Rather than remove 'filter:alpha' I'll add filter:kaiser-alpha and filter:kaiser-beta with filter:alpha mapping to (but not overriding if set) filter:kaiser-beta. that way he will not be effected, and the expert settings are more definitive.

Later I can remove filter:alpha.


DONE - comitted into SVN. values are set in the order
default 6.5
"filter:alpha"
"filter:kaiser-beta"
"filter:kaiser-alpha" * PI
the latter overriding the former. (unless you declare 'beta' should override 'alpha' :-)
NOTE: "filter:alpha" is to be depreciated in IMv7 at a later date.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply