Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- img = plt.imread("Q2.tif")
- N,M = np.shape(img)
- i, j = np.meshgrid(np.arange(M), np.arange(N))
- mult_factor = np.power( np.ones((N,M)) * -1 , i + j )
- tmp = img * mult_factor
- print("Calculating DFT")
- dft = np.fft.fft2(tmp)
- print("Calculating inverse DFT")
- idft = np.fft.ifft2(dft.conj())
- out_img = np.abs((mult_factor * idft.real) + (1j * idft.imag))
Add Comment
Please, Sign In to add comment