为什么FFT不自动产生以零频率为中心的输出? [英] Why doesn't FFT automatically produce a zero-frequency centered output?

查看:128
本文介绍了为什么FFT不自动产生以零频率为中心的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在DFT之后执行一项名为 Shift 的操作,以将零频率分量移到频谱的中心.

There is an operation called Shift which is performed after DFT to bring zero-frequency components to the center of the frequency spectrum.

关于此操作,我有两个问题:

I have two questions regarding this operation:

  1. 为什么DFT不能/不能自动将零频分量居中?
  2. 如果DFT之后我们不执行 Shift 操作会怎样? IE.它如何影响我们的其他图像处理任务?
  3. 有人可以向我提供一些资料来了解名为 Shift 的特定操作吗?
  1. Why don't/can't DFT automatically center the zero-frequency components?
  2. What happens if we don't perform Shift operation after DFT? I.e. how does it affect our other tasks of image processing?
  3. Can anyone provide me some material to know about this specific operation named Shift?

参考文献:
- fftw将零频移到图像中心
-为什么我们将零频率分量移到频谱中心吗?

References:
- fftw shift zero-frequency to the image center
- Why we shift the zero-frequency component to the center of the spectrum?

推荐答案

根据定义, DFT 使用n=0..N-1k=0..N-1,其中n是到时域信号的索引,而k是到时域信号的索引. k也对应于频率. DFT的定义类似于傅里叶级数.

The DFT, by definition, uses n=0..N-1 and k=0..N-1, where n is the index into the time-domain signal and k the index into the frequency-domain signal. k also corresponds to the frequency. The DFT is defined this way in analogy to Fourier series.

由于DFT中的频率是周期性的,因此可以想到k=N-1对应于k=-1.因此,移位函数将频率的上半部分移到原点的左侧,因此可以更容易地将它们解释为负频率.但这只是显示上的方便,因为它将频域信号带到我们更熟悉的形式(这可能是因为它使某些傅立叶分析更容易解释,因此教科书以此方式显示它,因此,我们通过查看频率图(其原点在中间)来了解傅里叶.

Since the frequency in the DFT is periodic, one can think of k=N-1 to correspond to k=-1 instead. The shift function thus moves the upper half of the frequencies to the left of the origin, so they can be more readily interpreted as negative frequencies. But this is solely a convenience for display, as it brings the frequency-domain signal to a form that we're more familiar with (this is probably because it makes some Fourier analysis easier to explain, and hence text books display it this way, and hence we learn about Fourier by looking at Frequency plots with the origin in the middle).

对于图像处理中的大多数任务,我们不需要移动原点.同样,这只是为了显示,这既方便又美观.

For most tasks in image processing, we do not need to shift the origin. Again, it is only for display that this is convenient and pretty.

例如,要计算互相关:

cc = ifft( fft(img1) * conj(fft(img2)) )

在这里,cc的左上像素是原点.如果img1==img2,则左上像素将是最大值.如果我们有一个fft函数将原点移动到中间,那么互相关图像cc的原点也将在中间.找到峰值后,我们需要进行一些计算以找出img1img2之间的偏移. (并不是说这很复杂,但它表明换档不一定是有利的.)

Here, the top-left pixel of cc is the origin. If img1==img2, the top-left pixel will be the maximum value. If we had an fft function that shifted the origin to the middle, then the cross-correlation image cc would have its origin in the middle also. After finding the peak, we'd need to do some computations to figure out what the shift between img1 and img2 is. (Not that this is complicated, but it shows that shifting is not necessarily advantageous.)

进行卷积时,通常会有一个空间域内核,其起源在中间(例如,在最近的问题中).在这种情况下,必须先计算原点到左上角,然后再计算DFT.但是仅仅将频域信号的原点乘以它们,然后撤消该偏移就没有任何意义.可以简单地将原点位于左上角的信号直接相乘:

When convolving, one often has a spatial-domain kernel with the origin in the middle (as for example in this recent question). In this case, one must shift the origin to the top-left before computing the DFT. But there is no point in shifting the origin of the frequency-domain signals just to multiply them together and then undo the shift. One can simply directly multiply the signals that have the origin in the top-left corner:

kernel = ifftshift(kernel)
filtered = ifft( fft(img) * fft(kernel) )

请注意,有两个不同的移位函数,通常称为fftshiftifftshift.一个将原点从左上方移动到中间,另一个将原点从中间移动到左上方.这两个函数对偶数大小的信号(图像)执行完全相同的操作,但是如果大小为奇数则不同.

Note that there are two different shift functions, often called fftshift and ifftshift. The one shifts the origin from the top-left to the middle, the other shifts the origin from the middle to the top-left. These two functions do exactly the same thing for even-sized signals (images), but differ if the sizes are odd.

这篇关于为什么FFT不自动产生以零频率为中心的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆