My function's output differs from conv2() output

感情迁移 提交于 2019-12-13 18:38:42

问题


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:

Here's conv2() output:


回答1:


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.



来源:https://stackoverflow.com/questions/22974801/my-functions-output-differs-from-conv2-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!