I don’t know how to evaluate it, I don’t know what I got rid of when I got rid of the Fourier transform, I don’t know whether I succeeded or failed, but it was fun to animate

There are a lot of modules that need to be installed. I don’t know when I installed a lot of modules… Put in whichever is missing.

Code:

from skimage import data, io
import numpy as np
from scipy.fftpack import fft,ifft
import matplotlib.pyplot as plt
from matplotlib.pylab import mpl
import matplotlib.animation as ani 
mpl.rcParams['font.sans-serif'] = ['SimHei']   # display Chinese
mpl.rcParams['axes.unicode_minus'] =False       # display the negative sign

# Animation update method
def update(i) :
    # img1 = 255 - img1 # Invert color switch
    max_t = max1 * m[i]
    fft_img1[ fft_img1 > max_t ] = 0
    fft_img1[ fft_img1 < -max_t ] = 0
    ifft_img1 = ifft(fft_img1)
    img1 = np.short(ifft_img1.T)
    # img1 = 255 - img1 # Invert color switch
    img1.shape = img_shape
    plt.title(tle[i])
    return plt.imshow(img1, animated=True),

# Get cat pictures
img = data.chelsea()
# Save the image shape
img_shape = img.shape
# One-dimensional three channels
img.shape = -1.3
Transpose is easy to transform
img = img.T
fft_img1 = fft(img)
# inverse transformation
ifft_img1 = ifft(fft_img1)
# transpose the number back and convert it to an integer from 0 to 256
img1 = np.short(ifft_img1.T)
# Convert the three channels into their original shapes again
img1.shape = img_shape
max1 = np.abs(fft_img1).max()
m = [1.0.9.0.65.0.3.0.1.0.05.0.005.0.001.0.0005.0.0001]
tle = ['original'.'90%'.'65%'.'30%'.'10%'.'5%'.'0.5%'.'0.1%'.'0.05%'.'0.01%']
fig,ax = plt.subplots()
ani1 = ani.FuncAnimation(fig, update, np.arange(0.10), interval=200, blit=True,repeat=False)
# ani1.save(' cat faded.gif', writer='imagemagick') # Save the GIF
plt.show()
Fft_img1 [fft_IMg1 >= max_t] = 0 fft_img1[fft_IMg1 <= -max_t] = 0 ifft_img1 = iFFT (fft_img1) Img1 = np.short(ifft_img1.t) img1 = 255-img1 img1.shape = img_Shape plt.title(" Color white ") plt.imshow(img1) plt.show() ' ' '
I'm going to remove it from the low frequencies, it's going to get more and more fuzzy fft_img1 = FFT (img) iFFt_img1 = iFFT (fft_IMg1) # transpose back, Img_shape m = [0.001, 0.004, 0.008, img_shape m = [0.001, 0.004, 0.008, img_shape m = [0.001, 0.004, 0.008, 0.024, 0.05, 0.1, 0.3, 0.6] tle = [' original ', '0.1%', '0.4%', '0.8%', '2.4%', '5%', '10%', '30%', '60%'] for I in range (7) : Subplot (2,4, I + 1) plt.title(tle[I]) plt.imshow(img1) max_t = max1 * m[I] fft_img1[(fft_img1 < max_t) & (fft_img1 > -max_t)] = 0 ifft_img1 = ifft(fft_img1) img1 = np.short(ifft_img1.t) img1.shape = img_shape plt.subplot(2,4,8) plt.title(tle[7]) plt.imshow(img1) plt.show() '''
Copy the code