import cv2 import numpy as np # from matplotlib import pyplot as plt img = cv2.imread('messi5.jpg',0) f = np.fft.fft2(img) fshift = np.fft.fftshift(f) magnitude_spectrum = 20*np.log(np.abs(fshift)) print magnitude_spectrum #cv2.imshow('input',f) rows, cols = img.shape crow,ccol = rows/2 , cols/2 fshift[crow-30:crow+30, ccol-30:ccol+30] = 0 f_ishift = np.fft.ifftshift(fshift) img_back = np.fft.ifft2(f_ishift) img_back = np.abs(img_back) cv2.imshow('input',img) cv2.imshow('transformada abs',img_back) if cv2.waitKey(0) == 27: cv2.destroyAllWindows()