import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
image = mpimg.imread('stock_bw_1.jpg')
plt.imshow(image)
<matplotlib.image.AxesImage at 0xb1521c8c>
#plt.imshow(image)
human_readable_fimage = np.fft.fftshift(np.fft.fft2(image))
machine_readable_fimage = np.fft.fft2(image)
#len(fimage), len(fimage[0]), fimage
#plt.imshow(fimage)
#plt.imshow(np.real(np.fft.ifft(fimage)))
#plt.imshow(np.real(fimage))
plt.imshow(np.abs(human_readable_fimage))
<matplotlib.image.AxesImage at 0xb1429bec>
plt.imshow(np.abs(np.fft.ifft2(machine_readable_fimage)))
<matplotlib.image.AxesImage at 0xb143806c>
#len(machine_readable_fimage[0])
temp = np.zeros([len(machine_readable_fimage), len(machine_readable_fimage[0]),3])
#temp[:,0:50] = machine_readable_fimage[:,0:50] - works
temp[400:450,0:100] = machine_readable_fimage[400:450,0:100]
#temp[:,0:50].shape
plt.imshow(np.abs(np.fft.ifft2(temp)))
<matplotlib.image.AxesImage at 0xa6837e6c>
plt.imshow(np.abs(temp))
<matplotlib.image.AxesImage at 0xa67fe8ec>
machine_readable_fimage.shape
(469, 450, 3)
len(machine_readable_fimage)
469