Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D Filter Jinc appears to be wrong #5

Open
torridgristle opened this issue Jul 24, 2022 · 3 comments
Open

2D Filter Jinc appears to be wrong #5

torridgristle opened this issue Jul 24, 2022 · 3 comments

Comments

@torridgristle
Copy link

Here is a plot of the generated 1D sinc filter kernel.
sinc looks right

Here is a plot of the generated 2D jinc filter kernel.
jinc looks wrong

I'd expect it to look more like a series of rings or ripples, rather than a donut or torus.

jinc filtered noise fft

The FFT output for randn noise put through the 2D filter doesn't look right either.

change jinc to sinc in 2d filter

Changing filter_ = 2 * cutoff * window * jinc(2 * cutoff * time) to filter_ = 2 * cutoff * window * sinc(2 * cutoff * time) in kaiser_jinc_filter2d makes a more familiar kernel.

change jinc to sinc in 2d filter fft out

And the FFT output for randn noise put through this 2D filter looks about how I'd expect.

@junjun3518
Copy link
Owner

I really appreciate your great issues!

I did not notice that i1 is modified Bessel function at that time.
For now it seems better that replace all wrong jinc as sinc to maintain 2d options.

Please tell me if you have any better idea.
Thank you for your issues again!

@torridgristle
Copy link
Author

torridgristle commented Jul 27, 2022

SciPy has a Bessel function, scipy.special.j1(). I can't find an implementation of it elsewhere that looks correct when I recreate it.

Edit: There's a Jinc function that keeps to basic Python and PyTorch in rosinality's Alias-Free GAN repo.

@junjun3518
Copy link
Owner

Thank you for good references!

Oh, he took polynomial approximation coefficients from outside.
Since my first goal is understandable and flexible code with pytorch, sinc is not a bad option for now.
In addition, I think that I need more study for jinc for better implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants