Clean image_to_fourier.py

This commit is contained in:
Benjamin Loison 2024-05-16 01:39:06 +02:00
parent eb33def18c
commit da5b19f047
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -3,19 +3,13 @@ import numpy as np
from scipy import fftpack
import matplotlib.pyplot as plt
image = np.array(Image.open('image_4.png').convert('L'))# / 255
print(image)
image = np.array(Image.open('circle.png').convert('L'))# / 255
# fft of image
# fftpack.fftshift
fft1 = (fftpack.fft2(image))
height, width = fft1.shape
for x in range(width):
fft1[height // 2, x] = np.median(fft1[:, x])
fft1 = fftpack.fftshift(fftpack.fft2(image))
# save the image
# np.log10
plt.imshow(np.log10(abs(fft1)))
toDisplay = np.log10(abs(fft1))
plt.imshow(toDisplay)
plt.show()
#plt.imsave('ifft1.png', np.log10(abs(fft1)))
plt.imsave('ifft1.png', toDisplay)