Hi everybody,
I am new in programming and I would like to apply a filter on an image in frequency domain. actually, its from a paper and i want to re implement it. its the formula: im_out= (1+ 5*((1-e^-f)/f)) * im_in and here are my codes:
im = cv2.imread('lena.jpg',0) x=im.shape[0] y=im.shape[1] fft= np.fft.fft2(im) fshift= np.fft.fftshift(fft) freqx = np.fft.fftfreq(fft.shape[0]) freqy = np.fft.fftfreq(fft.shape[1]) zr = freqx==0 freqx[zr]=0.000000001 for i in xrange(x): for j in xrange(y): filter = 1+(5(1-np.e(-1(np.sqrt((freqx)2 + (freqy)2))))/(np.sqrt((freqx)2 + (freqy)**2)))
fim= fshift* filter fishift= np.fft.ifftshift(fim) imback=np.fft.ifft2(fishift) imback=np.uint8(np.real(imback)) plt.subplot(221) plt.imshow(im,cmap='gray') plt.subplot(222) plt.imshow(imback,cmap='gray') plt.show()
but i get the image without any visible changes, it should be kind of low pass filter. now I am wondering if its correct to use np.fft.fftfreq to find "spatial frequency in the image plane". or I should use distance from center as "f"?!!! in the paper they said "f" is spatial frequency of the image plane!!!!
could anybody help me plz !!!