fft2 / ifft2的比例因子改变了中间矩阵的大小

时间:2022-03-20 06:47:02

Because of optimizations I change the size of my matrix when in the frequency domain. I'm not sure how to compensate with the scale factors. Currently I do it like this but I'm not certain it's correct:

由于优化,我在频域中更改矩阵的大小。我不确定如何补偿比例因子。目前我这样做但我不确定它是否正确:

B1 = fft2(A1)/numel(A1);
B2 = B1(idx1, idx2); %Cut out some parts of B1
A2 = fft2(B2); %I want the sign change

Does this scale properly? If so, please show.

这是否适当缩放?如果是,请显示。

EDIT: Changed multiplication with numel to division

编辑:将乘数和数字改为除法

1 个解决方案

#1


If your apply fft and ifft sequentially, you may not worry about scaling, they are going to compensate each other meaning ifft(fft(A)) equals exactly A. But in your case, when the size is changed, just do

如果你按顺序应用fft和ifft,你可能不会担心缩放,它们会相互补偿意味着ifft(fft(A))等于A。但在你的情况下,当大小改变时,只需做

B1 = fft2(A1);
B2 = B1(idx1, idx2);
A2 = numel(B2)/numel(B1)*ifft2(B2);

Note, in the code, you have shown above, you did not apply the inverse Fourier transform second time, that might cause an error.

请注意,在上面显示的代码中,您没有第二次应用逆傅立叶变换,这可能会导致错误。

#1


If your apply fft and ifft sequentially, you may not worry about scaling, they are going to compensate each other meaning ifft(fft(A)) equals exactly A. But in your case, when the size is changed, just do

如果你按顺序应用fft和ifft,你可能不会担心缩放,它们会相互补偿意味着ifft(fft(A))等于A。但在你的情况下,当大小改变时,只需做

B1 = fft2(A1);
B2 = B1(idx1, idx2);
A2 = numel(B2)/numel(B1)*ifft2(B2);

Note, in the code, you have shown above, you did not apply the inverse Fourier transform second time, that might cause an error.

请注意,在上面显示的代码中,您没有第二次应用逆傅立叶变换,这可能会导致错误。