0
// 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;

我需要这种在哈里斯角上实现的内核掩码的理论。那是什么样的内核掩码?那是prewitt还是任何不同的内核?我很难找到可以解释内核掩码的论文

4

1 回答 1

0

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.

于 2018-05-13T05:34:11.687 回答