static DSPFLOAT *BandPassKernel (DSPFLOAT *v, int16_t fsize, DSPFLOAT Fcl, DSPFLOAT Fch) { DSPFLOAT sumA = 0.0; DSPFLOAT sumB = 0.0; int16_t i; DSPFLOAT tmp1 [fsize]; DSPFLOAT tmp2 [fsize]; if ((Fcl > 0.5) || (Fch <= Fcl) || (Fch > 0.5)) { fprintf (stderr, "bandpasskernel ??? (%f, %f) %d\n", (float)Fcl, (float)Fch, fsize); Fcl = 0.2; Fch = 0.4; } sumA = Blackman (tmp1, fsize, Fcl); sumB = Blackman (tmp2, fsize, Fch); /* normalize */ for (i = 0; i < fsize; i ++) { tmp1 [i] = tmp1 [i] / sumA; tmp2 [i] = - tmp2 [i] / sumB; v [i] = - (tmp1 [i] + tmp2 [i]); } return v; }
/* * the validity of the hilbertshift was validated * by computing (and displaying) * arg (res - DSPCOMPLEX (real (res), real (res))) * where res = ... -> Pass (s1, s1) */ void HilbertFilter::adjustFilter (DSPFLOAT centre) { DSPFLOAT *v1 = (DSPFLOAT *)alloca (firsize * sizeof (DSPFLOAT)); DSPFLOAT sum = Blackman (v1, firsize, centre); int16_t i; for (i = 0; i < firsize; i ++) v1 [i] = v1 [i] / sum; for (i = 0; i < firsize; i ++) { DSPFLOAT omega = 2.0 * M_PI * centre; cosKernel [i] = v1 [i] * cos (omega * (i - ((DSPFLOAT)firsize - 1) / (2.0 * rate))); sinKernel [i] = v1 [i] * sin (omega * (i - ((DSPFLOAT)firsize - 1) / (2.0 * rate))); Buffer [i] = 0; } ip = 0; }
bool IPLFFT::processInputData(IPLImage* image , int, bool) { // delete previous result delete _result; _result = NULL; int width = image->width(); int height = image->height(); int cWidth = IPLComplexImage::nextPowerOf2(width); int cHeight = IPLComplexImage::nextPowerOf2(height); int size = cHeight = cWidth = (cWidth>cHeight)? cWidth : cHeight; _result = new IPLComplexImage(cWidth, cHeight); // get properties int mode = getProcessPropertyInt("mode"); int progress = 0; int maxProgress = image->height() * image->getNumberOfPlanes(); // image center int dx = ( cWidth - width )/2; int dy = ( cHeight - height )/2; IPLImagePlane* plane = image->plane(0); for(int y=0; y<height; y++) { // progress notifyProgressEventHandler(100*progress++/maxProgress); for(int x=0; x<width; x++) { _result->c(x+dx, y+dy) = Complex(plane->p(x,y), 0.0); } } // windowing function switch(mode) { case 0: // rectangular break; case 1: // Hanning for( int y=0; y<size; y++ ) for( int x=0; x<size; x++ ) _result->c(x,y) *= Hanning(x, size) * Hanning(y, size); break; case 2: // Hamming for( int y=0; y<size; y++ ) for( int x=0; x<size; x++ ) _result->c(x,y) *= Hamming(x, size) * Hamming(y, size); break; case 3: // Blackman for( int y=0; y<size; y++ ) for( int x=0; x<size; x++ ) _result->c(x,y) *= Blackman(x, size) * Blackman(y, size); break; case 4: // Border only int border = size / 32; for( int y=0; y<border; y++ ) for( int x=0; x<size; x++ ) { double factor = (0.54 - 0.46 * cos( 2.0 * PI * y / border / 2.0 )); _result->c(x,y) *= factor; _result->c(x,size-y-1) *= factor; } for( int x=0; x<border; x++ ) for( int y=0; y<size; y++ ) { double factor = (0.54 - 0.46 * cos( 2.0 * PI * x / border / 2.0 )); _result->c(x,y) *= factor; _result->c(size-x-1,y) *= factor; } break; } _result->FFT(); return true; }
static double BlackmanSinc(const double x, const double support) { return(Blackman(x/support,support)*Sinc(x,support)); }
static double BlackmanBessel(const double x, const double support) { return(Blackman(x/support,support)*Bessel(x,support)); }