我的函数的输出不同于conv2()输出 [英] My function's output differs from conv2() output

查看:224
本文介绍了我的函数的输出不同于conv2()输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我编写的用x方向Sobel掩码对图像进行卷积的代码。该函数输入灰度图像以及要卷积的核。但是,我得到的结果与从内置conv2()函数获得的结果不同。这是为什么?

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?

这是我的函数输出:

这里是conv2()输出:

Here's conv2() output:

推荐答案

您正在计算相关性。 2D卷积是内核的180度旋转(翻转两个轴)。

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.

这篇关于我的函数的输出不同于conv2()输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆