Image filtering in frequency domain python

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:

x=im.shape

y=im.shape

fft= np.fft.fft2(im)

fshift= np.fft.fftshift(fft)

freqx = np.fft.fftfreq(fft.shape)

freqy = np.fft.fftfreq(fft.shape)

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 !!!

edit retag close merge delete