import numpy as np

def butterworth_filter(inpt, omega_c=100, n=1.4):
  f = np.fft.fft2(inpt)
  f = np.fft.fftshift(f)
  signal = f.copy()
  shp = signal.shape
  y,x = np.meshgrid(np.arange(shp[0]),np.arange(shp[1]))
  omega = np.sqrt((y-shp[1]/2)**2+(x-shp[0]/2)**2)
  #omega_c = shp[1]*0.05
  filter_b = np.sqrt(1 / (1 + (omega/omega_c)**(2*n)))
  #ampl = complex(signal.real, signal.imag)*filter_b
  ampl = signal * filter_b
  signal = np.fft.ifftshift(ampl)
  res = np.fft.ifft2(signal, axes=[0,1])
  return res.real

