【发布时间】:2012-05-01 19:17:06
【问题描述】:
再次,我仍在尝试让我的低通滤波器运行,但我现在不知道为什么它仍然没有运行。我根据FFT Filters 和我之前的问题FFT Question 调整了我的代码,以便对图像应用理想的低通滤波器。下面的代码只是使图像变暗并在结果图像中放置一些白色像素。
// forward fft the result is in freqBuffer
fftw_execute(forward);
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
uint gid = y * w + x;
// shifting coordinates normalized to [-0.5 ... 0.5]
double xN = (x - (w / 2)) / (double)w;
double yN = (y - (h / 2)) / (double)h;
// max radius
double maxR = sqrt(0.5f * 0.5f + 0.5f * 0.5f);
// current radius normalized to [0 .. 1]
double r = sqrt(xN * xN + yN * yN) / maxR ;
// filter response
double filter = r > 0.7f ? 0.0f : 1.0f;
// applying filter response
freqBuffer[gid][0] *= filter;
freqBuffer[gid][1] *= filter;
}
}
// normlization (see fftw scaling)
for (uint i = 0; i < size; i++)
{
freqBuffer[i][0] /= (float)size;
freqBuffer[i][1] /= (float)size;
}
// backward fft
fftw_execute(backward);
我们将不胜感激。
狼
【问题讨论】:
-
对于任意内容,砖墙过滤器(将 FFT 箱归零)远非理想。
-
据我所知,这种行为被称为“理想”,请参阅Ideal Low Pass
-
请注意,此过滤器是连续的,其行为与 FFT bin 的行为非常不同(其中响应在 bin 中心之间可能有巨大的过冲,而不是平坦,如图所示)。
-
这正是我所经历的。所以我用余弦过渡的过滤器代替了它,它更平滑。结果比理想滤波器的结果要理想得多。 :-D
标签: fft fftw lowpass-filter