如何执行FFT2D(快速傅里叶变换2D)R,G,B颜色分量 [英] How to perform FFT2D (Fast Fourier Transform 2D) R, G, B color component

查看:1139
本文介绍了如何执行FFT2D(快速傅里叶变换2D)R,G,B颜色分量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新的快速傅立叶变换(FFT),没有太多想法,它如何在编程语言如C ++中计算。这里是FFT2D的方法

  void FFT2D(Complex< double> * f,Complex< double> * F,int width,int高度); 
它需要一个大小为width * height的输入图像f,并将转换后的
系数输出为F.


b $ b

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



我需要实现一个颜色组件的处理和编程模板将基于实现的功能分别处理R,G,B。模板还将使用零填充图像,以使每个输入图像的大小为2m * 2n。

 如果我从另一个类调用,我必须单独传递R,G,B 
假设:
Complex< double> * R = new Complex< double> [width * height];
让,width = 4096和height 4096
计算R颜色分量的FFT2D(R,输出F,宽度,高度)
用于计算G颜色分量的FFT2D(G,输出F,宽度,高度)
用于计算B颜色分量的FFT2D(B,输出F,宽度,高度)

我们有计算FFT1D函数的模板:
void FFT1D(Complex< double> * fx,Complex< double> * Fu,int twoK,int stride)
提示:输出阵列Fu中的频率系数。

FFT1D是从FFT2D函数内部调用 em>。我发现几种不同类型的代码在C,C ++,和Java和C#的FFT2D。其中大多数都采用二维阵列结构实现;它们在行和列的循环中将实部和虚部分配给2D阵列结构。但是,在我的例子中是颜色组件的1D数组结构。



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

 复杂< double> * outPutMap = new Complex< double> [width * height]; 
for(int i = 0; i #for(int j = 0; j #outPutMap [i + j * width] = f [i + j * width];
#我不明白如何实现在这里的颜色组件和如何
#它分配一个值的实部和虚部
#}
}

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



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



谢谢



尊重
Ichiro

解决方案

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



http://www.amazon。



FFT,Simpsons Rule,Fouriers Algorith应该都在那里。我从一个名叫Rajaram的作家那里读过。它是在C。


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

解决方案

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.

这篇关于如何执行FFT2D(快速傅里叶变换2D)R,G,B颜色分量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆