如何在C中使用给定的FFT函数?

发布于 2024-09-28 07:02:51 字数 655 浏览 0 评论 0原文

抱歉,这是我第一次在这里提出问题,我已经给出了 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)。

我的问题是:

  1. 我可以获得给定图像的每个强度值,但是如何处理 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:

  1. 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] and float xi[256] in order to do the 2D (DFT) of the image?

Thanks for your attention!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄居者 2024-10-05 07:02:51

图像通常是纯实数函数。因此,在调用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文