Guest User

Untitled

a guest
Jan 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import numpy as np
  2.  
  3. img = plt.imread("Q2.tif")
  4. N,M = np.shape(img)
  5. i, j = np.meshgrid(np.arange(M), np.arange(N))
  6. mult_factor = np.power( np.ones((N,M)) * -1 , i + j )
  7. tmp = img * mult_factor
  8. print("Calculating DFT")
  9. dft = np.fft.fft2(tmp)
  10. print("Calculating inverse DFT")
  11. idft = np.fft.ifft2(dft.conj())
  12. out_img = np.abs((mult_factor * idft.real) + (1j * idft.imag))
Add Comment
Please, Sign In to add comment