문제

Below is the code I have written to convolve an image with a x-direction Sobel mask. The function inputs a gray-scale image along with a kernel to be convolved with. However, the result I am getting is different compared to the result I get from the built-in conv2() function. Why is that? What am I doing wrong?

Here's my function's output:

enter image description here

Here's conv2() output:

enter image description here

도움이 되었습니까?

해결책

You are computing the correlation. The 2D convolution is a 180 degree rotation (flip both axes) of the kernel.

h = rot90(h,2);

You won't notice the difference with a symmetric filter, like a Gaussian or an averaging kernel, but a derivative will be reversed in both directions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top