如何执行 FFT2D(快速傅里叶变换 2D)R、G、B 颜色分量

发布于 2024-12-17 16:08:18 字数 1830 浏览 3 评论 0原文

我是快速傅立叶变换 (FFT) 的新手,不太了解它如何用 C++ 等编程语言进行计算。以下是 FFT2D 的方法

void FFT2D(Complex<double> *f, Complex<double> *F, int width, int height);
It takes an input image f of size width * height and output the transformed 
coefficients into F.

提示: 图像像素存储为三个独立的图像颜色(R、G、B)平面,每个平面都由一个一维复数数组表示。假设图像的尺寸为宽度 W 和高度 H,则图像位置 (m, n) 处像素的颜色分量值 (R、G 和 B) 可以计算为 R[m + n * W], G( m + n * W) 和 B[m + n * W],其中 R、G、B 是三个复数数组。 变换系数的一维数组也以相同的方式表示。

我只需要实现对一种颜色分量的处理,编程模板将根据实现的功能分别处理R、G、B。该模板还将用零填充图像,以便每个输入图像的大小为 2m * 2n。

If I called from another class, I have to pass R, G, B separately
Suppose: 
Complex<double> *R = new Complex<double>[width * height];
Let, width = 4096 and height 4096
FFT2D(R, output F, width, height) for compute “R” color component;
FFT2D(G, output F, width, height) for compute “G” color component;
FFT2D(B, output F, width, height) for compute “B” color component;

We have template of calculated FFT1D function:
void FFT1D(Complex<double> *fx, Complex<double> *Fu, int twoK, int stride)
Hint: it outputs the frequency coefficients in the array Fu.

FFT1D 正在从 FFT2D 的函数内部调用。我在 FFT2D 的 C、C++、Java 和 C# 中发现了几种不同类型的代码。大多数都是使用二维数组结构来实现的;他们将实部和虚部分配给行和列循环中的二维数组结构。然而,在我的例子中是颜色分量的一维数组结构。

让我们做一些代码,这是在 FFT2D 函数内部:

Complex<double> *outPutMap = new Complex<double>[width * height];
 for (int i = 0; i < height; i++){
 #  for(int j = 0; j < width; j++){
 #     outPutMap[i + j * width] = f[i + j * width];
 #      I don’t understand how to implement in here for color component and how 
 #      it assign a value for real and imaginary part
 #   }
  }

在调用 FFTID 之前,还需要像书中那样计算 2K 的值,M = 2K

如果您有任何想法或任何参考,请告诉我。

谢谢您的

问候 一郎

I am new in fast fourier transform (FFT) and does not have much idea, how it calculate in programming language such as C++. Here is method of FFT2D

void FFT2D(Complex<double> *f, Complex<double> *F, int width, int height);
It takes an input image f of size width * height and output the transformed 
coefficients into F.

Hints: Image pixels are stored as three separate image color (R, G, B) planes, with each of them being represented by a 1D array of complex numbers. Suppose an image is of size width W and height H, then the color component values (R, G and B) of the pixels at image location (m, n) can be found as R[m + n * W], G(m + n * W) and B[m + n * W], where R, G, B are the three arrays of complex numbers.
The 1D array for the transformed coefficients is also represents in the same manner.

What I need to implement the processing for one color component only and the programming template will process the R, G, B separately based on implemented functions. The template will also pad the image with zeros so that each input image is of size 2m * 2n.

If I called from another class, I have to pass R, G, B separately
Suppose: 
Complex<double> *R = new Complex<double>[width * height];
Let, width = 4096 and height 4096
FFT2D(R, output F, width, height) for compute “R” color component;
FFT2D(G, output F, width, height) for compute “G” color component;
FFT2D(B, output F, width, height) for compute “B” color component;

We have template of calculated FFT1D function:
void FFT1D(Complex<double> *fx, Complex<double> *Fu, int twoK, int stride)
Hint: it outputs the frequency coefficients in the array Fu.

FFT1D is calling from inside a function of FFT2D. I found several different type of code in C, C++, and Java and C #of FFT2D. Most of them have implemented using 2D array structure; they assign real and imaginary part to 2D array structure in loop of rows and columns. However, in my case is 1D array structure of color component.

Let's, do some code and this is inside FFT2D function:

Complex<double> *outPutMap = new Complex<double>[width * height];
 for (int i = 0; i < height; i++){
 #  for(int j = 0; j < width; j++){
 #     outPutMap[i + j * width] = f[i + j * width];
 #      I don’t understand how to implement in here for color component and how 
 #      it assign a value for real and imaginary part
 #   }
  }

Before, calling a FFTID, it also required calculate a value of twoK as in book, M = 2K

If you have any idea or any reference please let me know.

Thank you

Regards
Ichiro

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

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

发布评论

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

评论(1

朱染 2024-12-24 16:08:18

我建议你买一本书,例如 [Numerical Recipes][1] 。

http://www.amazon.com/Numerical-Recipes-Art-Scientific-Computing/ dp/0521750334

FFT、辛普森规则、傅立叶算法都应该在那里。我读过一位名叫 Rajaram 的作者的文章。它是用 C 语言编写的。

I would suggest you get hold of a book such as [Numerical Recipes][1] .

http://www.amazon.com/Numerical-Recipes-Art-Scientific-Computing/dp/0521750334

FFT, Simpsons Rule, Fouriers Algorith should all be there. I had read from an author named Rajaram .. it was in C.

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