March 2018
Beginner to intermediate
306 pages
9h 54m
English
The following steps must be performed:
import cv2import numpy as npimport matplotlib.pyplot as plt
image = cv2.imread('../data/Lena.png', 0).astype(np.float32) / 255
fft = cv2.dft(image, flags=cv2.DFT_COMPLEX_OUTPUT)
shifted = np.fft.fftshift(fft, axes=[0, 1])magnitude = cv2.magnitude(shifted[:, :, 0], shifted[:, :, 1])magnitude = np.log(magnitude)plt.axis('off')plt.imshow(magnitude, cmap='gray')plt.tight_layout()plt.show()
restored = cv2.idft(fft, flags=cv2.DFT_SCALE | cv2.DFT_REAL_OUTPUT) ...