Closed mpizenberg closed 2 years ago
IDCT2 is a DCT3. So, compute a DCT2, do your processing, then compute a DCT3 on the processed data.
At some point within those steps (doesn't matter when), you'll need to scale each element by 1/N (or 1/(2N)?).
Ah, I see that matlab's dct2 is actually a 2D transform, not just 1D. So the steps are slightly more complicated.
To replicate the effects of dct2
, on 2D array of size MxN:
data.chunks_exact_mut(M)
and compute a DCT of size M on each chunktranspose
crate for a fast implementation of this)data.chunks_exact_mut(N)
and compute a DCT of size N on each chunkAnd idct
is the exact same thing, but with DCT3 instead of DCT2.
I looked up the normalization, and it's 2/N * 2/M
, IE 4 / N*M
. So you'll have to scale each element by that much, at some point in the process.
Thank you! I'll try that and let you know how it goes.
Hi, I'm just getting back to this after a long pause. I'll let you know soon how that goes but my first experiments with the fft library are working well so I'm getting back at this normals integration via dct now.
Side question, I've noticed that rustfft
is now at version 6. And it seems from my quick check that everything is compatible with rust_dct. I'm getting all the code and tests / benches running normally. Do you mind if I make a PR to update the dependency? Or do you prefer do it yourself / or just leave it as is and not bother?
It worked like a charm! thanks again for the help. Here are some images extracted for the examples of the fft2d
crate I just published, reusing your rustfft
and rustdct
crates.
Low pass filtering with 2D Fourier transform:
Normal integration with a Poisson solver via a 2D DCT transform:
If you make a PR to upgrade rustdct with v6 of rustfft, i'd be happy to accept it.
On Thu, Dec 9, 2021 at 2:23 PM Matthieu Pizenberg @.***> wrote:
It worked like a charm! thanks again for the help. Here are some images extracted for the examples of the fft2d https://github.com/mpizenberg/fft2d crate I just published, reusing your rustfft and rustdct crates.
Low pass filtering with 2D Fourier transform:
[image: fft2d_low_pass] https://user-images.githubusercontent.com/2905865/145476357-d15a5785-3204-47e3-8293-4bd5fc560738.jpg
Normal integration with a Poisson solver via a 2D DCT transform:
[image: fft2d_normal_integration] https://user-images.githubusercontent.com/2905865/145479695-1a915993-3435-4cbb-a97e-e5b0fcd3ce18.jpg
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ejmahler/rust_dct/issues/8#issuecomment-990347513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI2M6T7T5JQYECJ5ZLJSI3UQET6ZANCNFSM4WHM23XA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi, I'm currently working on a photometric stereo project and in need of a 2D cosine transform to reconstruct the surface volume with normal integration. Basically I'm trying to port this matlab function: https://github.com/yqueau/normal_integration/blob/master/Toolbox/DCT_Poisson.m. I haven't done signal processing things like fft and dct in a while so I don't remember much what the different dct types of this crate refer to.
I was wondering if you could point me in the correct direction on how to use this crate to write the
dct2
andidct2
matlab functions used here and there and if there might be normalization pitfalls I could avoid.Btw, awesome performance work of rustfft!