我在实现 LoG 内核时遇到了问题。我正在尝试使用 theta = 1.4 实现 9x9 内核,如此链接中所示 http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm .
但是,我对公式本身有困难。如果有人能告诉我如何计算中心,即使用什么 x 和 y 值才能在 9x9 内核中获得 -40,我将不胜感激。
最佳答案
您无需担心公式 - 仅用于生成系数。您只需要将这些 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;
}
}
关于image-processing - 高斯拉普拉斯算子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2556958/