matlab—— ifftshift,fftshift

版权声明:double12754 https://blog.csdn.net/double12754/article/details/88393258
  1. fft(转换到频域)得到的像谱默认不是按照中心对称的(快速傅里叶变换的原因),一般需要用fftshift方法使得其按中心对称,这样的话当我们ifft时(转换回时域),得到的数据就会和之前实际的不一样了,所以还需加ifftshift 来还原。

  2. fft是一维的傅里叶变换,是将时域信号转换为频域信号的 fftshift是这针对频域信号的,将fft的DC分量移到频谱中心区,
    而iffshift是fftshift的逆运算,将fftshift还原。

  3. Ifftshift和fftshift两者实际上是不同的。首先,ifftshift和fftshift执行的都是圆周位移的操作。fftshift是将数组或矩阵按正方向(向右和向下)做圆周位移,而ifftshift是按负方向(向左和向上)做圆周位移。圆周位移的步长等于数组或矩阵长度的一半,对于偶数是N/2,对于奇数是(N-1)/2。这也就是为什么对于偶数长的数组,fftshift和ifftshift的结果相同,而对于奇数长的数组,两者结果却不一样的原因。
    例子:
    A=[1,2,3,4,5];
    B=fftshift(A)=[4,5,1,2,3]; 12345整体向右移动(5-1)/2=2位
    C=ifftshift(A)=[3,4,5,1,2];12345整体向左移动(5-1)/2=2位
    两次fftshift不能使数列恢复原状,而要如下使用
    ifftshift(fftshift(A))=A

少了omega = ifftshift(omega);

在这里插入图片描述
有omega = ifftshift(omega);
在这里插入图片描述

结论:ifftshift可以改善信号图像。

补充:(可以不看)
fftshift的作用正是让正半轴部分和负半轴部分的图像分别关于各自的中心对称。因为直接用fft得出的数据与频率不是对应的,fftshift可以纠正过来
以下是Matlab的帮助文件中对fftshift的说明:
Y = fftshift(X) rearranges the outputs of fft, fft2, and fftn by moving the zero-frequency component to the center of the array. It is useful for visualizing a Fourier transform with the zero-frequency component in the middle of the spectrum. For vectors, fftshift(X) swaps the left and right halves of X.
例子如下:
clear;
clc;
t=0:0.001:2;
n=2001;
Fs=1000;
Fc=200;
x=cos(2piFc*t);
y1=fft(x);
y2=fftshift(y1);
f=(0:2000)*Fs/n-Fs/2;
hold on;
plot(f,abs(y1),‘r’)
plot(f,abs(y2),‘b’)

猜你喜欢

转载自blog.csdn.net/double12754/article/details/88393258
今日推荐