/* * Compute weights for a log point spaces critical band filter. * * @param window is the length of FFT to compute relative frequency. * @param points is the length of filter kernel. */ void cbweights(double *filter, int window, int points) { int i, center; double step, w; center = points/2; step = pow((double)window, 1.0/(window-1.0)); filter[center] = butter(1.0); w = 1; for (i = 1; i <= points/2; i++) { w *= step; /* w = pow(step, (double)i); */ filter[center+i] = filter[center-i] = butter(w); } }
// makes the butterworth mask for a shifted dft by multiplying the coefficient to the dst void butterFilter(cv::Mat_<float> &dst, int u, int v, float D0, int n){ int p = dst.rows; int q = dst.cols; for(int row = 0; row < p; row++){ for(int col = 0; col < q; col++){ dst.at<float>(row, col) = dst.at<float>(row, col) * butter(row - u, col + v, D0, n, p, q) * butter(row + u, col - v, D0, n, p, q); } } }
int main() { int offset; double wr, mag, step; step = pow(N, 1.0/(N-1)); for (offset = -15; offset <= 15; offset++) { wr = pow(step, (double)offset); mag = butter(wr); printf("%4d: %f, %f, %f\n", offset, wr, mag, 20.0*log10(mag)); } return 0; }