dft

FFT on image with Python

£可爱£侵袭症+ 提交于 2019-12-21 10:18:04
问题 I have a problem with FFT implementation in Python. I have completely strange results. Ok so, I want to open image, get value of every pixel in RGB, then I need to use fft on it, and convert to image again. My steps: 1) I'm opening image with PIL library in Python like this from PIL import Image im = Image.open("test.png") 2) I'm getting pixels pixels = list(im.getdata()) 3) I'm seperate every pixel to r,g,b values for x in range(width): for y in range(height): r,g,b = pixels[x*width+y] red[x

FFT\\NTT总结

允我心安 提交于 2019-12-19 13:16:02
学了好久,终于基本弄明白了 推荐两个博客: 戳我 戳我 再推荐几本书: 《ACM/ICPC算法基础训练教程》 《组合数学》(清华大学出版社) 《高中数学选修》 预备知识 复数方面 找数学老师去 \[i^{2}=-1,i为虚数的单位\] 坐标系上纵轴就是虚数轴,复数就是这上面的点 三种表示法: \[一般:a + bi,a为实部,b为虚部\] \[指数:e^{i\theta}*坐标系上的模长\] \[三角:模长*(cos\theta + i sin \theta)\] 运算: 加减法:实部虚部分别相加 乘法: \[(a + bi) * (c + di) = ac + adi + bci + bdi^{2} = ac-bd+(ad+bc)i\] 欧拉公式 \[e^{ix} = cosx + isinx(就是指数表示和三角表示)\] \[特别的e^{i\pi} = -1\] 多项式 \[系数表示法:A(x) = \Sigma _{k=0}^{n - 1} a_kx^k\] \[点值表示法:对于所有的x_k,求出它们对应的A(x),设为y_k\] \[则可以用\{(x_0, y_0), (x_1, y_1), ......, (x_n-1, y_n-1)\} 表示这个多项式 并且是唯一确定的\] 单位复数根 \[n次单位复数根\omega^{n} = 1,n次单位复数根刚好有n个对应e^{

FFT real/imaginary/abs parts interpretation

匆匆过客 提交于 2019-12-18 11:17:15
问题 I'm currently learning about discret Fourier transform and I'm playing with numpy to understand it better. I tried to plot a "sin x sin x sin" signal and obtained a clean FFT with 4 non-zero points. I naively told myself : "well, if I plot a "sin + sin + sin + sin" signal with these amplitudes and frequencies, I should obtain the same "sin x sin x sin" signal, right? Well... not exactly (First is "x" signal, second is "+" signal) Both share the same amplitudes/frequencies, but are not the

DSP - Filtering in the frequency domain via FFT

微笑、不失礼 提交于 2019-12-17 10:22:26
问题 I've been playing around a little with the Exocortex implementation of the FFT, but I'm having some problems. Whenever I modify the amplitudes of the frequency bins before calling the iFFT the resulting signal contains some clicks and pops, especially when low frequencies are present in the signal (like drums or basses). However, this does not happen if I attenuate all the bins by the same factor. Let me put an example of the output buffer of a 4-sample FFT: // Bin 0 (DC) FFTOut[0] = 0

离散傅里叶变换

╄→гoц情女王★ 提交于 2019-12-16 16:30:19
傅里叶变换将信号分解为正弦波,离散傅里叶变换DFT基于数字信号。real DFT是将输入输出信号都用实数表示,一般用复数DFT,但实数DFT是基础。 傅里叶变换族 傅里叶变换是傅里叶在研究热传导时发现的,他提出用正弦波代表温度分布并向法兰西学会提交论文。但当时的法兰西学会权威拉格朗日对此理论并不赞成,拉格朗日认为傅里叶的方法不能代表非连续信号。实际上拉格朗日某些条件下是对的,因为正弦波之和确实无法表示非连续信号,但却可以无限接近,即两者能量无限接近。这种现象叫做吉布斯效应。当信号为离散信号时傅里叶分解完全成立,拉格朗日所拒绝的是连续信号。 一个16点长度信号被分解为正弦信号和余弦信号,如下图所示: 如上图所示傅里叶分解将此信号分解为9个正弦信号和9个余弦信号。每个都有不同的幅度和频率。至于为何选用正弦波而不是三角波或者方波进行分解,这主要正弦信号特有的特性:正弦信号保真度。正弦信号输入到一个系统中其输出仍为正弦信号,其频率和波形保持不变,只有其幅度和相位发生改变。正弦曲线是唯一有此特性的波。 傅里叶变换可以根据4种不同信号分为4类,信号可以是离散或者连续的,也可能是周期的或者非周期的。因此可以分为以下4类: 非周期连续 这种信号傅里叶变换简单的叫做傅里叶变换FT 周期连续 这种信号傅里叶变换叫做傅里叶级数FS 非周期离散 这种信号傅里叶变换叫做离散时间傅里叶变换DTFT 周期离散

离散傅里叶变换(DFT)

给你一囗甜甜゛ 提交于 2019-12-16 16:27:00
目录 一、研究的意义 二、DFT的定义 三、DFT与傅里叶变换和Z变换的关系 四、DFT的周期性 五、matlab实验 五.1 程序 五.2 实验结果 一、研究的意义 DTFT计算公式,中的w取值是连续的而且从负无穷大到正无穷大,对于计算机处理是不可能的,需要无限细分无限区间。即使在DTFT小节中用matlab实现计算,也只是将(-pi,pi)区间划分成1600份来逼近DTFT的效果。 实际上真正用的是DFT,离散傅里叶变换。离散傅里叶变换可以将连续的频谱转化成离散的频谱去计算,这样就易于计算机编程实现傅里叶变换的计算。FFT算法的出现,使得DFT的计算速度更快。 二、DFT的定义 由上边的定义可知,w=(2*pi/N)*k ,k=0,1,......,N-1,所以w的范围为[0,(N-1/N)*2*pi]。因为是离散取值,实际的区间长度为N,但不含第N个点,w的范围就是[0,2*pi)。 也就是说DFT变换的频谱范围是在竖轴的右侧(>0),而且取了FT变换的一个周期(0,2*pi)。 三、DFT与傅里叶变换和Z变换的关系 四、DFT的周期性 以下的四个式子,在程序设计和理解程序中经常用到,wd、wa分别为数字角频率和其对应的模拟角频率。 (1) ,描述了模拟角频率、数字角频率以及DFT变换的k之间的对应关系 (2) ,描述了数字角频率与模拟角频率之间的关系 (3)

Calculating nth Roots of Unity in Python

ε祈祈猫儿з 提交于 2019-12-13 15:35:39
问题 So, I'm trying to write an algorithm croot(k, n), that returns the kth root of unity with n == n. I'm getting mostly the right answer, however it's giving me really weird representations that seem wrong for certain numbers. Here is an example. import cmath def croot(k, n): if n<=0: return None return cmath.exp((2 * cmath.pi * 1j * k) / n) for k in range(8): print croot(k, 8) Output is: (1+0j) (0.70710...+0.70710...j) (6.12323399574e-17+1j) Whoa whoa whoa. So the root when k = 2 and n = 8 is

OpenCV find image frequencies

被刻印的时光 ゝ 提交于 2019-12-13 12:09:48
问题 I am trying to find the dominant frequencies in an image using OpenCV. I saw the dft example in the OpenCV tutorial but how can I find the dominant frequencies of an image with periodic structures? I want to extract the spectral informations of the lowest harmonics, copy them to a new image and do reverse dft. A sample image is attached to this question. 来源: https://stackoverflow.com/questions/13720683/opencv-find-image-frequencies

Is this Fourier Analysis of Luminance Signals Correct? (Android)

回眸只為那壹抹淺笑 提交于 2019-12-13 08:40:59
问题 I'm writing an Android app that measures the luminance of camera frames over a period of time and calculates a heart beat using Fourier Analysis to find the wave's frequency. The problem is that my spectral analysis looks like this: which is pretty much the inverse of what a spectral analysis should look like (like a normal distribution). Can I accurately assess this to find the index of the maximum magnitude, or does this spectrum reveal that my data is too noisy? EDIT: Here's what my camera

2D Fourier Transformation in C

纵饮孤独 提交于 2019-12-12 18:35:31
问题 I implemented 2D DFT and IDFT using equation from this site http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm I think these are correct and nicely explained. Implementation looks like that: for(int i=0;i<inImage.width;i++) { for(int j=0;j<inImage.height;j++) { float ak=0; float bk=0; for(int ii=0;ii<inImage.width;ii++) { for(int jj=0;jj<inImage.height;jj++) { float x=-2.0*PI*i*ii/(float)inImage.width; float y=-2.0*PI*j*jj/(float)inImage.height; // ak+=inImage.pixels[i][j]*(cos(x)*cos(y)-sin