Guest User

Untitled

a guest
Jan 16th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import numpy as np
  2. from matplotlib import pyplot as plt
  3.  
  4. img = plt.imread("Q4.tif")
  5. dft = np.fft.fft2(img)
  6. dft_of_dft = np.fft.fft2(dft)
  7.  
  8. spectrum = np.abs(dft)
  9. c = 255 / log(1 + np.amax(spectrum))
  10. spectrum = c*np.log(spectrum)
  11.  
  12. double_dft_spectrum = np.abs(dft_of_dft)
  13. c = 255 / log(1 + np.amax(double_dft_spectrum))
  14. double_dft_spectrum = c*np.log(double_dft_spectrum)
  15.  
  16. p, axarr = plt.subplots(1, 3, figsize=(12,4))
  17. axarr[0].imshow(img, cmap = 'gray')
  18. axarr[0].set_title('Original Image')
  19. axarr[1].imshow(spectrum, cmap = 'gray')
  20. axarr[1].set_title('DFT')
  21. axarr[2].imshow(double_dft_spectrum, cmap = 'gray')
  22. axarr[2].set_title('Double DFT')
  23. plt.show()
Add Comment
Please, Sign In to add comment