FAQ Database Discussion Community


Performing a phase correlation with fft in R

r,image-processing,fft,cross-correlation
I am trying to implement a 2d phase correlation algorithm in R using a recipe from Wikipedia (http://en.wikipedia.org/wiki/Phase_correlation) in order to track the movement between 2 images. These images (frames) were captured with a camera shaking in the wind and the ultimate goal is to remove the shake in these...

High Pass filter matlab

matlab,signal-processing,fft
Im working on spectrum analysis of wav file. I have plotting the spectrum of the whole frequency,but how can i plot just the high frequency of my file ? this is the code : [a,fs] = wavread('ori1.wav'); ydft = fft(a); ydft = ydft(1:length(a)/2+1); freq = 0:fs/length(a):fs/2; plot(freq,abs(ydft)); ...

FFT using recursive python function

python,fft,rosetta-code
I am trying to use the following code for finding FFT of a given list. After a lot of trials I have found that this code runs only for an input list having 2^m or 2^m+1 elements. Can you please clarify why this is so and whether it can be...

real-to-complex FFT with JCufft

java,cuda,fft,jcuda
I'm doing a real-to-complex FFT with the org.apache.commons.math3.transform library as following: private Complex[] fft(double[] values) { FastFourierTransformer ffTransformer = new FastFourierTransformer(DftNormalization.STANDARD); Complex[] result = ffTransformer.transform(values, TransformType.FORWARD); return result; } This gives me a org.apache.commons.math3.complex array with the result. This works fine. Now I want to perform exactly the same with...

Convert an image to a 2D array of coordinates in Python for two point correlation

python,opencv,numpy,fft,correlation
I need to perform two-point correlation function from astroML Python module, my data is originally a jpg image, black and white, and I convert it to binary image using OpenCV image thresholding(not sure that I did it right). The question is how now I convert the 2D binary matrix or...

Reducing a FFT spectrum range

audio,numpy,fft,spectrum,nyquist
I am currently running Python's Numpy fft on 44100Hz audio samples which gives me a working frequency range of 0Hz - 22050Hz (thanks Nyquist). Once I use fft on those time domain values, I have 128 points in my fft spectrum giving me 172Hz for each frequency bin size. I...

Matlab Low Pass filter using fft

matlab,filtering,fft,lowpass-filter
I implemented a simple low pass filter in matlab using a forward and backward fft. It works in principle, but the minimum and maximum values differ from the original. signal = data; %% fourier spectrum % number of elements in fft NFFT = 1024; % fft of data Y =...

Audioread in matlab of wav file and FFT

matlab,audio,signal-processing,fft
I'm working on Matlab, I want to perform FFT on a wav file I previously recorded on Matlab as well. fs = 44100; % Hz t = 0:1/fs:1; % seconds f = 600; % Hz y = sin(2.*pi.*f.*t); audiowrite('600freq.wav',y,fs) This is the way I'm recording in the wav file. Now...

What is frequency-domain entropy in FFT result and how to calculate it?

signal-processing,fft,software-defined-radio
I am a programmer but quit bad on math.. I recently read an article which mentioned frequency-domain entropy,he calculated that thing from a FFT power spectrum but didn't tell me how to do that. I cannot find enough information online to understand what it is . I'm appreciate for any...

Fast Fourier Transform in Objective-C doesn't work fine

objective-c,signal-processing,fft,accelerate-framework
I have a method in Objective-C that receives an array of doubles and then it uses the Fast Fourier Transform, however the exit of the FFT doesn't match to what I want. Can someone help me, I don't know what I'm doing wrong? This is my method where fftLength is...

Parallel calculation and record matlab

matlab,audio,fft,audio-recording
Hello I want to calculate realtime FFT plot of my input. With the following code i create a record and calculation. The point is that the calculation is takes to much time to get i nice plot update. Fs = 44100; % sampling frequency in Hz T = 1/5; %...

Python FFT & Magnitude Spectrum of two similar signals have different frequencies

python,signal-processing,fft
My goal is to compare the FFT of similar signals. For some reason, when I take the magnitude spectrum of two signals of the same length, the frequencies are different... I can't do a simple side by side comparison of two signals because of this. Anyone have any tips on...

FFT: find and cut noisy 50Hz in signal

python,signal-processing,fft
I have noisy data (peaks with period 1.8s, 2048 bins per period) for which I want to calculate frequency and delete 50Hz. I'm pretty sure that frequency what I looking for is 50Hz, cause I find it by use originlab. When I try to do the same in python the...

Why extreme large value to 0 frequency fft (numpy.fft.fft method)

numpy,scipy,fft
I have a signal ts which has rougly mean 40 and applied fft on that with code ts = array([25, 40, 30, 40, 29, 48, 36, 32, 34, 38, 15, 33, 40, 32, 41, 25, 37,49, 41, 35, 23, 22, 36, 44, 28, 36, 32, 37, 39, 51]) index =...

Level out FFT graph (Processing)

java,processing,fft,visualization,music
I am trying to make a music visualizer in Processing, not that that part is super important, and I'm using a fast fourier transform through Minim. It's working perfectly (reading the data), but there is a large spike on the left (bass) end. What's the best way to 'level' this...

How can I define the period before fitting a Fourier series to discrete data using MATLAB?

matlab,function,fft,series
I'm using MATLAB's fit function: fourier_series=(x,y,'fourier8'); to fit an 8th order Fourier series to a set of discrete data (x,y). I need the period of the Fourier series to be 2*pi. However I can't work out how to fix this so that when I call the function it fits the...

2D complex FFT implementation

c,multidimensional-array,fft,fftw
I'm working in C with Dev-C++ I've created a 2D array of complex numbers as such: #include<complex.h> double complex **x; x = malloc(Nx * sizeof *X); if (x) { for (i = 0; i < Nx; i++) { x[i] = malloc(Nx * sizeof *x[i]); } And filled it with data,...

Fourier Analysis - MATLAB

matlab,function,plot,fft,frequency-analysis
Good evening guys, I wanna ask you a question regarding the analysis of a function in the domain of frequencies (Fourier). I have two vectors: one containing 7700 values for pressure, and the other one containing 7700 values (same number) for time. For example, I call the firt vector "a"...

Polynomial multiplication in M2(R)?

algorithm,matrix,fft,polynomials
I was trying to implement a FFT-based multiplication algorithm in M2(R). Basically an algorithm that gets as an input two polynoms with elements given as matrices, and builds the product polynom. However, even though the algorithm should work, as it looks exactly identical to a version I wrote earlier on...

Speeding up analysis on arrays in numpy

python,performance,numpy,multiprocessing,fft
I have a python code, which imports 4 column txt file with numbers first three columns are x,y,z coordinate and fourth column is a density at that coordinate. below is the code that reads, converts to ndarray, Fourier transform that field, calculate the distance from origin (k=(0,0,0)) and a transformed...

Perform action on all data

r,fft
I have a lot of csv files with data. I want to perform the same action on all my files, but I do not know how to do this without doing it individually for all the files. I read in all the csv files and saved the data in my...

FFT Filter on Complex Numbers in Python

python,audio,numpy,filter,fft
My question is related to the explanation here by A. Levy: Analyze audio using Fast Fourier Transform How can I produce a bandpass filter on these complex numbers... [-636.00000000 +0.00000000e+00j -47.84161618 -2.80509841e+02j 30.69754505 -1.30624718e+01j -109.94022791 +7.58155488e+00j -3.18538186 +1.44880882e+01j -120.36687555 +5.45225425e+00j 50.48671763 +1.69504204e+01j 31.56751791 -7.22728042e+01j -17.96079093 -3.17853727e+01j -19.25527276 +5.08151876e+00j 18.38143611 -2.60879726e+01j...

Trouble with Fourier Transform using fftpack5.1

fortran,fft,fftpack
I have an issue using the FFTPACK5.1 in Fortran 90 which contains subroutines to compute discrete Fourier transforms. I manage to install it and use the routines but when I'm checking if everything is ok with a simple sine wave with a frequency A I get a non zero coefficient...

DFT of sine(x) using FFTW in Fortran muddled output

fortran,fft,fftw,dft
The following is the code I have written to find the DFT of sine(x) over a period. program fftw_test implicit none INTEGER FFTW_MEASURE PARAMETER (FFTW_MEASURE=0) INTEGER FFTW_ESTIMATE PARAMETER (FFTW_ESTIMATE=64) INTEGER FFTW_FORWARD PARAMETER (FFTW_FORWARD=-1) integer, parameter :: n = 8 integer :: i double complex, dimension(0:n-1) :: input, output double precision,...

Confusion about scipy.fft function

python,audio,scipy,fft
I have an audio sample, which is sampled at 22k Hz and total samples = 660k , as the duration is 30 seconds. (22k*30 = 660k) When I plot the fft of the complete sample, I get a symmetric graph with 660k x values, and corresponding y values as shown:...

Different result value between openCV DFT and Matlab FFT

matlab,opencv,fft,dft
I'm trying to convert a simple matlab code doing FFT. The code goes like this: c = fft([y; zeros(N-M, 1)]); Values for N=256, M = 100. Here are the values of y (100 points) that i'm using to test: 0.504747377917058 0.897277682272301 0.151672365249603 0.355122573738706 0.553925412440538 0.158834350258486 0.356559717393412 0.267749785433509 0.739084139656738 0.166499777727771 0.473321012784302...

Why does the frequency spectra change when the sampling frequency is changed?

matlab,signal-processing,fft,frequency,continuous-fourier
Here is my code for generating a triangular waveform in the time domain and for generating its corresponding fourier series/transform (I don't know whether its series or transform because matlab only has fourier transform function but since the signal is periodic, references say that the fourier counterpart must be called...

DC Term in Python FFT - Amplitude of Constant Term

python,numpy,matplotlib,signal-processing,fft
I've created an FFT class/object that takes signal stored in a 2D array and produces the subsequent FFT of its input, before printing it to a matplotlib graph. After a great deal of reading, I appreciate that due to windowing, the need to have an ideally 2^x number of points...

trigger event on sound input pitch frequency

javascript,fft,eventtrigger
I'm trying to trigger an event from sound input pitch, I have this code https://webaudiodemos.appspot.com/pitchdetect/index.html but I'm searching for an easier way to de that. Please help me, thank's by advance. ...

How to deal with the output of np.fft?

python,numpy,fft
I am very confused of how to use the output of FFD , here is a example output generate by result = np.abs(fftpack.fft(targetArray))[0:sample_size/2] print result will gives a ndarray : [ 4.21477326e+05 3.03444591e+04 1.80682694e+04 1.05924224e+04 1.98799134e+04 2.82620258e+04 1.39538936e+04 2.40331051e+04 4.57465472e+04 6.41241587e+04 1.88203479e+04 1.88670469e+04 5.42137198e+03 5.97675834e+03 1.23986101e+04 9.70841580e+02 2.07380817e+04 4.52632516e+04 4.49493295e+04...

Generating Signals with Python

python,signals,fft
I was trying to generate signals into the raw way but I am getting the error below could somebody help me ? And yes I need it into the raw way and after I will generate the spectrum of it. Also, could someone gimme some hints of where could I...

frequency spectrum of sinc function in matlab shows me nothing

matlab,fft,matlab-figure
since i don't have sinc function in my MATLAB, I implemented that function as shown below %% time specificactions: Fs=10000; dt=1/Fs; t=(-0.1:dt:0.1-dt)'; N=size(t,1); %message signal mt=(sin(pi*100*t))./(pi*100*t); %% frequency specifications dF=Fs/N; f=-Fs/2:dF:Fs/2-dF; M=fftshift(fft(mt)); plot(f,abs(M)/N); but the figure shows me nothing but blank, so i looked up the variable table and it...

FFT algorithm usage

scala,fft
Im trying to understand how this FFT algorithm works. http://rosettacode.org/wiki/Fast_Fourier_transform#Scala def _fft(cSeq: Seq[Complex], direction: Complex, scalar: Int): Seq[Complex] = { if (cSeq.length == 1) { return cSeq } val n = cSeq.length assume(n % 2 == 0, "The Cooley-Tukey FFT algorithm only works when the length of the input is...

fftw of 16bit Audio :: peak appearing wrong at 2f

c++,audio,fft,fftw,portaudio
I am taking 32bit float audio(44.1Khz) on my PC(between -1 and +1) using Port Audio and taking fft of it with fftw. Now I need to take the 16bit int Audio and take its fft. I have converted the Audio samples to float between -1 and +1. The fft works...

Deconvolution of data convolved by a Gaussian response

matlab,filtering,signal-processing,fft
I have a set of experimental data s(t) which consists of a vector (with 81 points as a function of time t). From the physics, this is the result of the convolution of the system response e(t) with a probe p(t), which is a Gaussian (actually a laser pulse). In...

How to calculate a sum of products of array elements using a fast Fourier transform?

c++,arrays,c++11,sum,fft
I have some binary array. For example, let my array is: int a[] = {1, 0, 0, 0, 1, 0, 1, 0, 1} I want to calculate the values based on this formula: How to calculate this function, using a fast Fourier transform? I have a large array and I...

How to Inverse FFT in Arduino

arduino,fft,ifft
I am trying to filter some data based on the the following code using Arduino FFT library for FFT (fast Fourier transform) /* fft_adc_serial.pde guest openmusiclabs.com 7.7.14 example sketch for testing the fft library. it takes in data on ADC0 (Analog0) and processes them with the fft. the data is...

Numpy FFT (Fast Fourier Transformation) of 1-dimensional array

python,arrays,opencv,numpy,fft
I have a simple one-dimensional array like [0,0,0,0,0,1,1,1,1,1,0,0,0,0,0] which describes a square impulse. I would like to transform this impulse to the frequency domain and plot its magnitude spectrum by using the code below (I got it from OpenCV Python Tutorials): squareimpulse = np.array([0,0,0,0,0,1,1,1,1,1,0,0,0,0,0]) img = (squareimpulse) f = np.fft.fft(img)...

Parseval's theorem doesn't work with ifft

python,signal-processing,fft
I have a temporal signal and I calculate its Fourier Transform to get the frequencial signal. According to Parseval's theorem, the two signals have the same energy. I successfully demonstrate it with Python. However, when I calculate the inverse Fourier Transform of the frequencial signal, the energy is no longer...

Length of FFT and IFFT

c++,matlab,fft,fftw,frequency-analysis
I have some signals and I mix respectively add up to a larger signal, where each signal is located in different frequency regions. Now, I perform the FFT operation on the big signal with FFTW and cut the concrete FFT bins (where the signals are located) out. E.g. The big...

Scipy FFT Frequency Analysis of very noisy signal

python,numpy,pandas,fft
I have noisy data for which I want to calculate frequency and amplitude. The samples were collected every 1/100th sec. From trends, I believe frequency to be ~ 0.3 When I use numpy fft module, I end up getting very high frequency (36.32 /sec) which is clearly not correct. I...

Calculate frequency from FFT sample?

c++,fft,frequency-analysis,unreal-engine4
I'm using the below code in Unreal Engine 4 to capture microphone input and get the resulting FFT. I'm having trouble calculating the frequency based on this data. I've tried finding the max amplitude and taking that as the frequency, but that doesn't seem to be correct. // Additional includes:...

Determine amplitude of low frequency signals using FFT

c#,audio,signal-processing,fft
I am totally new to signal processing and am trying to make a program that shows the amplitude of low frequency signals in a PCM (WAV) file. So far, I've been able to read in the WAV file and populate an array (actually a multi-dimensional array, one for each channel,...

STFT Clarification (FFT for real-time input)

fft
I get how the DFT via correlation works, and use that as a basis for understanding the results of the FFT. If I have a discrete signal that was sampled at 44.1kHz, then that means if I were to take 1s of data, I would have 44,100 samples. In order...

GFortran: Not passing arrays between f03 and f90?

arrays,fortran,fft,fortran90,gfortran
I am a novice in Fortran programming but I have started using code::blocks with Fortran plugin. I am trying to pass variables between my code (f03) and fftsg.f (code from http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html) to calculate fft. fftsg.f contains a subroutine called rdft (real discrete Fourier transform) that I try to use to...

calculate discrete S transform for given discrete time series

matlab,loops,fft,wavelet
let us consider following Page : http://djj.ee.ntu.edu.tw/S_Transform.pdf paragraph 2.3 The Discrete S Transform let say that we have sampled version of signal x, and given sampling frequency fs,i have calculated discrete Fourier transform using following code function y=DFT(x); N=length(x); D=zeros(N,N); for k=1:N for n=1: N D(k,n)=exp((-j*(k-1)*2*pi*(n-1))/N); end end y=D*x'/N; end...

kissfft - Inverse Real FFT gives NaN

c++,fft,kissfft
The real inverse FFT gives me an array full of NaNs instead of floats. kiss_fftri(conf,complex_array,output); The complex_array is normal, nothing wrong with the values i guess. kiss_fftr_cfg conf = kiss_fftr_alloc(size,1,NULL,NULL); The conf should be fine too as far as I know. Anything wrong with the size? I know that the...

What is the range of the values returned by analyser.getByteFrequencyData in the web audio API?

javascript,fft,web-audio
I would like to work with percentages while doing some FFT with the web audio API. To do so I need to know the range of the values the analyser.getByteFrequencyData returns. I can't find anything about that, maybe someone knows? Thanks...

cuFFT runs slowly - any way to accelerate?

performance,cuda,fft
I am using cufft to calculate 1D fft along each row for a matrix, and an array. The matrix size is 512 (x) X 720 (y), and the size of the array is 512 X 1. Which means the fft is applied on each row that has 512 elements for...

zero padded FFT using FFTW

fft,fftw
To interpolate a signal in frequency domain, one can pad zeros in time domain and do an FFT. Suppose the number of elements in a given vector X is N and Y is the same as X but padded one sided with N zeros. Then the following give the same...

How do I apply the hanning function to my audio sample?

java,signal-processing,fft,audio-fingerprinting,windowing
I am a university student. I am developing a music identification system for my final year project. According to the "Robust Audio Fingerprint Extraction Algorithm Based on 2-D Chroma" research paper, the following functions should need to be included in my system. Capture Audio Signal ----> Framing Window (hanning window)...

FFT low-pass filter

python,numpy,scipy,filtering,fft
Be warned, this is a newbie question. I acquired some noisy data (a 1x200 pixel sclice from a grayscale image), for which I am trying to build a simple FFT low-pass filter. I do understand the general principle of the Fourier Transform, but I ran into trouble trying to implement...

My fourier series doesn't fit the graph

matlab,fft
I'm trying to plot a Fourier series that should fit the original graph (which is right), but I don't know what's wrong. I also double-checked the Fourier approximation. The original graph is generated with: t=-pi:0.01:0; x=ones(size(t)); plot(t,x) axis([-3*pi 3*pi -1 4]) hold on t=0:0.01:pi; y=cos(t); plot(t,y) whereas the Fourier series...

FFTW filled with zeros at the end

fft,complex-numbers,fftw
Can you help me find out why one of the FFTW's plans gives zeroes at the end of an output array? The "fftw_plan_dft_1d" yields proper result as I checked it with Matlab. The Real to Complex plan "fftw_plan_dft_r2c_1d" makes some zeroes at the end. I don't understand why. Here is...

Undefined function 'fft' for input arguments of type 'sym' MATLAB

matlab,fft
I am trying to make a frequency spectrum up to 30 Hz of a Sine wave with period pi. I wrote a code but I keep getting the error : Undefined function 'fft' for input arguments of type 'sym' sint = sin(t); Tmax = 2*pi; %the end sample value Ts...

Python amplitude spectrum plot

python,fft,spectrum
i'm kinda new to python and i had problem getting this to work, so since the deadline is for tomorrow, might as well ask the question here. I have two lists of float values, one for time and other for voltage values taken from an oscilloscope(i assume). I have to...

Syntax Error in Octave plotting

plot,fft,octave
I got the following syntax error while I want to plot values: syntax error >>> plot(freq1, abs(fft1/max(fft1)),xlabel('f(Hz)'), ylabel('Amplitude I(f)'); ^ My definitions are as follows: a=x+y+z; % a is a sinus mixture of different curves/functions n1 = fa/0.05; % N is 50 ms fft1=fft(a,n1); freq1 = [0:deltaF1:fa-fft1]; plot(freq1, abs(fft1/max(fft1)),xlabel('f(Hz)'), ylabel('Amplitude...

How to recognize Low/High/Band pass filters after FFT?

matlab,fft
I'm having two zero padded signals in Matlab h_1[n] = {...,0,0,1,2,1,0,0,...} h_2[n] = {...,0,1,0,2,0,1,0,...} and below you can see their FFT plots: % N1 and N2 are just the lengths of h1 and h2. H1 = fft(h1, N1); H2 = fft(h2, N2); % ... figure; from = -floor(length(H1)/2); to =...

SpanSelector with Fourier analysis

python,matplotlib,fft
I'm trying to use matplotlib widget SpanSelector to make find the frequencies of a plot at certain user-clicked intervals. I'm trying to do this using matplotlib widget SpanSelector but am unsure of how to do this. I tried modifying the example given http://matplotlib.org/examples/widgets/span_selector.html but it does not work and still...

Python u-law issues: unknown format: 7

python,numpy,format,fft,wav
I'm trying to compare two large sets of wav files to remove duplicates. The issue is that one set is PCM, the other has been u-law'd. When I try to read in PCM wav, no problem, but the u-law files give the following error: >>> wav = wave.open("C:\\soundfiles\\Olympus Recordings\\1019.wav") Traceback...