I am having trouble implementing a LoG kernel. I am trying to implement 9x9 kernal with theta = 1.4 as shown in this link http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm.
However, I am having difficulty with the formula itself. If someone could tell me how to calculate the center ie what x and y values to use in order to get -40 in the 9x9 kernel it'd be greatly appreciated.
You don't need to worry about the formula - that is just used to generate the coefficients. You just need to apply those 9x9 coefficients to your image.
Example (untested code !):
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With