Fourier image analysis in P5

Hello everyone!

I’ve been trying to make a little diffraction simulator and I’m struggling with finding 2D FFT and IFFT libraries to work along with P5.

The program I’m trying to do should do the following:

  1. Get a FFT of the aperture image;
  2. Get the FFT of the image;
  3. Multiply the magnitude of both;
  4. IFFT the result.

OpenCV.js’ FFT works just fine, but the library has no inverse function.

Has anyone tried (and hopefully succeeded) to do this? Any pointers on how to go about it?

Thank you in advance!