如何在C中使用给定的FFT函数?
抱歉,这是我第一次在这里提出问题,我已经给出了 FFT 函数
void fft_1d(int n, float xr[256], float xi[256], int ntype)
{
/* compute the FFT of a complex signal
xr and xi are the real and imaginary parts respectively
xr and xi contain the signal as input and the FT as output
n is the number of points, it should be a power of 2
ntype is set to 1 for forward transform and -1 for inverse transform
*/
,并且有人告诉我扩展此函数以对给定图像进行 2D (DFT)。
我的问题是:
- 我可以获得给定图像的每个强度值,但是如何处理 fft_1d 的复杂分量(实部/虚部)?换句话说,为了对图像进行 2D (DFT),我应该在参数
float xr[256]
和float xi[256]
中放入什么?
感谢您的关注!
Sorry this is the first time for me to ask question here, I've given a FFT function
void fft_1d(int n, float xr[256], float xi[256], int ntype)
{
/* compute the FFT of a complex signal
xr and xi are the real and imaginary parts respectively
xr and xi contain the signal as input and the FT as output
n is the number of points, it should be a power of 2
ntype is set to 1 for forward transform and -1 for inverse transform
*/
And I have been told to extend this function to do the 2D (DFT) of the given image.
My problem is:
- I can get every itensity value of the given image but how can I deal with the complex components (real part /imaginary part) of the fft_1d? In other words, what should I put in the parameters
float xr[256]
andfloat xi[256]
in order to do the 2D (DFT) of the image?
Thanks for your attention!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
图像通常是纯实数函数。因此,在调用FFT函数时,可以将实数输入设置为图像值,将虚数输入设置为零。
但是,为了执行 2D FFT,您必须首先对每行调用 1D FFT,然后对结果的每列调用 1D FFT。这些中间结果将很复杂,并且必须直接传递到第二组 FFT。
An image is, generally, a real-only function. Therefore, you can set the real inputs to be the image values, and the imaginary inputs to zero when calling the FFT function.
However, in order to perform a 2D FFT, you must first call the 1D FFT on each row, and then call the 1D FFT on each column of the results. These intermediate results will be complex, and must be passed as such to the second set of FFTs.