Skip to content

Instantly share code, notes, and snippets.

@mfornet
Created July 26, 2020 02:45
Show Gist options
  • Save mfornet/16ae00ea63d9e3aecf3b5facd398df9b to your computer and use it in GitHub Desktop.
Save mfornet/16ae00ea63d9e3aecf3b5facd398df9b to your computer and use it in GitHub Desktop.
Discover the animal
# %%%
import PIL.Image
import numpy as np
import matplotlib.pyplot as plt
# %%
im = PIL.Image.open("panda.jpeg")
arr = np.array(im).mean(2)
freq = np.fft.fft2(arr)
n, m = freq.shape
for i in range(n):
for j in range(m):
if min(i, j) >= 10:
freq[i, j] = 0
inv_arr = np.fft.ifft2(freq)
for i in range(n):
for j in range(m):
inv_arr[i, j] = abs(inv_arr[i, j]).real
inv_array = inv_arr.astype(float)
plt.imshow(inv_array, cmap='gray')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment