I feel like this should be a very standard thing to need to do, however I cannot find a function online ANYWHERE. Anyone have one? Thanks! David
Convolution function in c++
Started by ●January 26, 2007
Reply by ●January 26, 20072007-01-26
David wrote:> I feel like this should be a very standard thing to need to do, however I > cannot find a function online ANYWHERE. Anyone have one?So what do you want to convolve together? The simplest thing is to convolve two finite length vectors, akin y = conv(x,h). The next steps are streaming convolution (using circular buffers), block convolution (using overlap-add / save), and finally fast convolution (filtering in the frequency domain) with the different variants (single or multiply partitioned impulse responses). Different tricks and implementation issues apply at each step. You can also convolve images. Regards, Andor
Reply by ●January 26, 20072007-01-26
daviddoria wrote:> I feel like this should be a very standard thing to need to do, however I > cannot find a function online ANYWHERE. Anyone have one? > > Thanks! > > DavidIf you want to convolve two arrays it's pretty easy to program. Considering memory usage convolution is application specific, there is no best way for any given application. R.
Reply by ●January 26, 20072007-01-26
"daviddoria" <doriad@rpi.edu> wrote in message news:b-CdnSbFoswG2yfYnZ2dnUVZ_o-knZ2d@giganews.com...> > I feel like this should be a very standard thing to need to do, however I > cannot find a function online ANYWHERE. Anyone have one? > > Thanks! > > DavidIf you know the maths then surely the code follows? It's just multiplications,loops and sums of delayed arrays. F. -- Posted via a free Usenet account from http://www.teranews.com
Reply by ●January 27, 20072007-01-27
hi you have to select the type of convolution you want for your application. its fairly simple to write c/c++ code for that APS> >I feel like this should be a very standard thing to need to do, howeverI>cannot find a function online ANYWHERE. Anyone have one? > >Thanks! > >David >
Reply by ●January 27, 20072007-01-27
On Jan 27, 12:48 am, "salaria" <apsala...@gmail.com> wrote:> hi > > you have to select the type of convolution you want for your application. > its fairly simple to write c/c++ code for that > > APS > > > > > > >I feel like this should be a very standard thing to need to do, however > I > >cannot find a function online ANYWHERE. Anyone have one? > > >Thanks! > > >DavidTry the SPUC dsp library http://spuc.sourceforge.net. Create a FIR using one side of the equation and then loop on the update/clock function with the other inputs. If you are only doing a convolution though it's probably better to either just write the code yourself or copy the appropriate section out of this
Reply by ●January 29, 20072007-01-29
On Jan 26, 1:21 pm, "daviddoria" <dor...@rpi.edu> wrote:> I feel like this should be a very standard thing to need to do, however I > cannot find a function online ANYWHERE. Anyone have one? > > Thanks! > > DavidTry this: // Routine peforms linear convolution by straight forward calculation // calculates z= x convolve y // Written by Clay S. Turner // // inputs: // X array of data comprising vector #1 // Y array of data comprising vector #2 // Z pointer to place to save resulting data - needs to be lenx +leny-1 long // lenx # of items in vector 1 // leny # of items in vector 2 void LinearConvolution(double X[],double Y[], double Z[], int lenx, int leny) { double *zptr,s,*xp,*yp; int lenz; int i,n,n_lo,n_hi; lenz=lenx+leny-1; zptr=Z; for (i=0;i<lenz;i++) { s=0.0; n_lo=0>(i-leny+1)?0:i-leny+1; n_hi=lenx-1<i?lenx-1:i; xp=X+n_lo; yp=Y+i-n_lo; for (n=n_lo;n<=n_hi;n++) { s+=*xp * *yp; xp++; yp--; } *zptr=s; zptr++; } }
Reply by ●January 29, 20072007-01-29
A Gaussian High Pass Filter (MIT'S FFTW based) is available at: http://www.adislindia.com/login/pluginlinks.php It performs a convolution and is an extension of CFFTWWrapper (http:// divyarathore.googlepages.com/fftwpluginforimageapprentice.htm). - D. Rathore www.adislindia.com