如何应用傅里叶变换来提取图像中某些边缘的频率?

时间:2015-09-11 16:21:41

标签: python matlab image-processing fft

标题可能看起来有点不清楚,但我会告诉你整个故事,并希望对此有所评论。 我尝试在给定的图像中检测某些边缘,特别是那些比其他边缘更多的边缘。要做到这一点,最好的想法是傅里叶变换将离散像素域映射到频域。在应用傅立叶变换之前,我必须测量一些理想边缘的距离的平均值,然后使用傅里叶变换来找到它们的频率。问题是如何设置FFT算法的平均距离(在Python或Matlab上)。

谢谢

1 个答案:

答案 0 :(得分:1)

FFT将返回1number_of_samples/2之间每个重复元素的频率。

因此,您将在image_width/100附近寻找频率峰值。

如果您的FFT输出数组从零开始索引,FFT_array[0]将是稳态偏移,FFT_array[image_width/100]将是您正在寻找的峰值。

在伪代码中,您的函数将类似于:

image_full = # 2d array of pixel values ex: [[1,2,3],[4,5,6],[7,8,9]]
width_slice_center = image_full[int(len(image_full)/2)]
FFT_slice = FFT(width_slice_center)

#this is where you'll find the values that you are looking for
range = 5 #how far away from exactly 100px you want to look for edges
frequency_100 = int(len(image_full[0])/100) #how many times something 100px wide would appear in image
total_edges_signal = sum(FFT_slice[frequency_100-5:frequency_100+5]) #signal strength of edges in at given width

#then tune the total_edges_signal using an image with known edges
total_edges = int(total_edges_signal*tuning_parameter)

我尝试使伪代码尽可能通用,您应该能够修改这个想法以匹配许多数据类型。我希望这会有所帮助。