Ask Your Question
0

spatial frequency corresponding to the image plane

asked 2015-05-26 03:05:06 -0600

fery gravatar image

updated 2015-05-26 03:05:31 -0600

Hi everybody

I am doing image filtering in frequency domain, and I need to find the frequency of each image pixel . the only thing I know about the image is size of image for example: (225, 225)

There is a function in python "np.fft.fftfreq" to calculate frequencies, but two question arises here:

  1. Using this function, I have to find the frequency in x and y direction , so two numbers, but i need one number for each pixel (I need a matrix the same size as image fill with frequencies correspond to the image pixels)?

  2. it starts with zero!!! but as I know after shifting fft, DC component is in the middle so why zero at the beginning?

if anybody knows another way to calculate the frequencies, more than welcome :)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-05-29 07:21:13 -0600

fery gravatar image

I found the answer on my own, just for those who maybe have the same problem:

x=im.shape[0]
y=im.shape[1]
fft =  np.fft.fft2(im)
fshift = np.fft.fftshift(fft)
#the frequencies will be shifted to the center:
fshx=np.fft.fftshift(np.fft.fftfreq((fft.shape[0])))
fshy=np.fft.fftshift(np.fft.fftfreq((fft.shape[1])))
for i in xrange(x):
     for j in xrange(y):
         fre = np.sqrt(fshx[i]**2 + fshy[j]**2)

it works for me as I expected, hope its correct :P

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-26 03:05:06 -0600

Seen: 1,084 times

Last updated: May 29 '15