Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from matplotlib import pyplot as plt
- img = plt.imread("Q4.tif")
- dft = np.fft.fft2(img)
- dft_of_dft = np.fft.fft2(dft)
- spectrum = np.abs(dft)
- c = 255 / log(1 + np.amax(spectrum))
- spectrum = c*np.log(spectrum)
- double_dft_spectrum = np.abs(dft_of_dft)
- c = 255 / log(1 + np.amax(double_dft_spectrum))
- double_dft_spectrum = c*np.log(double_dft_spectrum)
- p, axarr = plt.subplots(1, 3, figsize=(12,4))
- axarr[0].imshow(img, cmap = 'gray')
- axarr[0].set_title('Original Image')
- axarr[1].imshow(spectrum, cmap = 'gray')
- axarr[1].set_title('DFT')
- axarr[2].imshow(double_dft_spectrum, cmap = 'gray')
- axarr[2].set_title('Double DFT')
- plt.show()
Add Comment
Please, Sign In to add comment