Don*_*Don 6 filtering image-processing laplacianofgaussian
我在实现LoG内核时遇到了麻烦.我正在尝试使用theta = 1.4实现9x9内核,如此链接http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm所示.
但是,我对配方本身有困难.如果有人能告诉我如何计算中心,即为了在9x9内核中获得-40而使用的x和y值,我们将不胜感激.
您无需担心公式 - 它仅用于生成系数。您只需将这些 9x9 系数应用到您的图像即可。
示例(未经测试的代码!):
const int K = 9;
const int K2 = K / 2;
const int NORM = 500; // constant for normalising filter gain
const int coeffs[K][K] = { ... };
int in_image[M][N];
int out_image[M][N];
for (i = K2; i < M - K2; ++i)
{
for (j = K2; j < N - K2; ++j)
{
int term = 0;
for (di = -K2; di <= K2; ++di)
{
for (dj = -K2; dj <= K2; ++dj)
{
term += in_image[i + di][j + dj] * coeff[K2 + ii][K2 + jj];
}
}
out_image = term / NORM;
}
}
Run Code Online (Sandbox Code Playgroud)