This is a Python implementation of Fast Fourier Transform (FFT) in 1d and 2d from scratch and some of its applications in:
- Photo restoration (paper texture pattern removal)
- convolution (direct fft and overlap add fft method, including a comparison with the direct matrix multiplication method and ground truth using
scipy.signal.convolve
. It also includes a speed and accuracy comparison withtorch.nn.Conv2d
) - large integer multiplication.
The honeycomb pattern on old photos is due to the "silk finish" paper texture, which was used a lot back in the day. We can remove them in frequency domain using fft.
achieves O(nlogn) complexity, whereas a direct matrix multiplication approach is O(n^2). It is more efficient when n is large.
inspired from the multiplication of polynomials in chap.30 of Introduction to algorithms book.