Last active
July 17, 2020 00:42
-
-
Save HiCraigChen/8774ff0cbf78e6142e0633e30670b256 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.figure(figsize=(6.4*5, 4.8*5), constrained_layout=False) | |
img_c1 = cv2.imread("left01.jpg", 0) | |
img_c2 = np.fft.fft2(img_c1) | |
img_c3 = np.fft.fftshift(img_c2) | |
img_c4 = np.fft.ifftshift(img_c3) | |
img_c5 = np.fft.ifft2(img_c4) | |
plt.subplot(151), plt.imshow(img_c1, "gray"), plt.title("Original Image") | |
plt.subplot(152), plt.imshow(np.log(1+np.abs(img_c2)), "gray"), plt.title("Spectrum") | |
plt.subplot(153), plt.imshow(np.log(1+np.abs(img_c3)), "gray"), plt.title("Centered Spectrum") | |
plt.subplot(154), plt.imshow(np.log(1+np.abs(img_c4)), "gray"), plt.title("Decentralized") | |
plt.subplot(155), plt.imshow(np.abs(img_c5), "gray"), plt.title("Processed Image") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment