本文介绍了Sobel面膜的困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sobel(Gx和Gy)的确切遮罩是什么?我看到的是人们如何编写它的两种类型,如下所示,

What is the exact mask for Sobel (Gx and Gy)? What I saw is there are two types on how people wrote it such as below,

样式1

Gx = [-1 -2 -1
        0 0 0
        1 2 1]

Gy = [-1 0 1
      -2 0 2
      -1 0 1]

样式2

Gx = [-1 0 1
      -2 0 2
      -1 0 1]

Gy = [-1 -2 -1
        0 0 0
        1 2 1]

已编辑

@Aurelis

在Matlab中->(第x行)

In Matlab --> (row x col)

在OpenCV中->(col x行)

In OpenCV --> (col x row)

但是,下面的图对两者都是正确的

However, the diagram below is correct for both

-->column
^
|row
|

在Matlab中,可能会输出Gx ==水平边缘,如果使用样式1,则输出Gy ==垂直边缘,而Gx ==水平边缘,如果使用样式2,则输出Gy ==垂直边缘.两者都会产生相同的输出(由于行的主要顺序,内部操作可能会有所不同).

Probably in Matlab will output Gx == horizontal edge, Gy == vertical edge if Style 1 is used and Gx == horizontal edge, Gy ==vertical edge if Style 2 is used. Both will produce same output (internal operation might be different due to the col-row major order).

@Abhishek您正在使用样式1计算水平和垂直边缘吗?和Gx对应于水平边缘,而Gy对应于垂直边缘?这是否意味着样式2是对此的补充?例如.计算Gx会给出垂直边缘,而Gy会给出水平边缘?

@Abhishek You are using style 1 to compute the horizontal and vertical edge? and Gx correspond to horizontal edge while Gy correspond to vertical edge?Does that mean style 2 is complement of that? For eg. computing Gx will gives vertical edge and Gy gives horizontal edge?

推荐答案

样式2是正确的.但是,使用两种样式,由于内核与图像卷积,我们将获得相同的结果

Style 2 is correct. However, using both the styles we will get the same result, as the kernels are convolved with the image

Gx = [-1 -2 -1 0 0 0 <---将在Y方向而不是X方向提取特征. 1 2 1]

Gx = [-1 -2 -1 0 0 0 <--- will extract features in Y direction and not in X direction. 1 2 1]

Gy = [-1 0 1 -2 0 2< ---将提取X方向而不是Y方向的特征. -1 0 1]

Gy = [-1 0 1 -2 0 2 <--- will extract features in X direction and not in Y direction. -1 0 1]

这可以通过使用简单的二维卷积来验证.

This can be verified by using a simple 2-D convolution.

原始图片:

使用Style1,Gx:

using Style1,Gx:

使用style1,Gy:

using style1, Gy:

这篇关于Sobel面膜的困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 16:08