首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >二维fft -空虚部

二维fft -空虚部
EN

Stack Overflow用户
提问于 2014-08-18 08:50:58
回答 1查看 431关注 0票数 0

我正在将Python例程集成到C++代码中。

在Python中使用了一些实矩阵的fft 2D的计算。

代码语言:javascript
复制
F_BLK=np.fft.fft2(blk)

F_BLK是一个复杂的512*24矩阵,系数复实,映射部分数量级为10e5。

在计算矩阵的fft2时,得到了一个复系数为的复矩阵,实部为10e6级,虚部为

  • ,如果fft2有空假想部分,这意味着什么?
  • 这种错误结果的可能来源是什么?
  • 您会推荐C++中的一个库来计算fft2吗?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-18 09:56:05

  1. 如果你用真正的输入进行FFT

代码语言:javascript
复制
- then you do not need to have so much calculations ( C += R \* C is simpler then C += C \* C)
- so if you have FFT C = f(R) coded for such input data then it is usually faster
- then standard FFT C= f(C)
- and also you do not need to have allocated memory for the input imaginary part
- also when input data is real only then the FFT output is symmetric
- so you can just compute only first half of output data and mirror the rest

  1. 震级差

代码语言:javascript
复制
- either you have wrong implementation of FFT (in python or in C++)
- or you just have different normalization coefficients
- plot the data and compare if the difference is just constant scale factor
- if not then you have bug in FFT implementation somewhere or the python FFT is not FFT
- also do not forget that data size for any FFT must be power of 2
- if your implementation expects that then also that could be the cause of error
- so try resize matrix 512x24 to 512x32 by zero padding before FFT
- another thing that can cause this can be overflow errors
- if you mix huge and small numbers together your accuracy get lost
- especially by FFT recursions the output magnitude can be 10e5 but the subresults can be much much bigger !!!

  1. 二维FFT

代码语言:javascript
复制
- look here [2D FFT,DCT by 1D FFT,DCT](https://stackoverflow.com/a/22779268/2521214)
- it contains slow 1D DFT,iDFT implementations in C++ (`R->C`,`C->R`)
- and algorithm how to compute 2D transforms with it
- with correct results so you can check yours

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25359433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档