Kernel Mask on Harris corner detection

1k Views Asked by At
// Convolution with horizontal differentiation kernel mask
float h = ((src[-srcStride + 1] + src[+1] + src[srcStride + 1]) -
          (src[-srcStride - 1] + src[-1] + src[srcStride - 1])) * 0.166666667f;

// Convolution vertical differentiation kernel mask
float v = ((src[+srcStride - 1] + src[+srcStride] + src[+srcStride + 1]) -
          (src[-srcStride - 1] + src[-srcStride] + src[-srcStride + 1])) * 0.166666667f;

I need theory for this kind of kernel mask which implemented on harris corner. What kind of kernel mask is that? Is that prewitt or any different kernel? I have difficulty to find a paper which can explain that kernel mask

1

There are 1 best solutions below

0
Cris Luengo On

That is indeed the Prewitt operator.

Following the indexing into src (the input image), with srcStride the number of array elements to skip to address the next neighbor in the y-direciton, one can see that h takes elements from src in the following order and with the following weights:

-1/6   0   1/6
-1/6   0   1/6
-1/6   0   1/6

This corresponds to a convolution with the following kernel (remember that the convolution mirrors the kernel):

| 1  0  -1 |
| 1  0  -1 | / 6
| 1  0  -1 |

This again corresponds the two convolutions

h = src * ( [1 0 -1] / 2 ) * ( [1 1 1]^T / 3 )

That is, it applies a derivative filter (central difference) horizontally, and a uniform smoothing filter vertically.

Note that the uniform smoothing filter has some very poor qualities (it will flip the sign of some frequency components, and does generally a poor job of smoothing), so it is always better to use Sobel's operator (which uses a triangular smoothing filter) or preferably Gaussian gradients.