相关疑难解决方法(0)

OpenCV 中的梯度方向

通过 Sobel 算子,我已经能够确定图像的梯度幅度。我在下面显示这个:

GradMag

现在我想确定梯度方向。为此,我关注了这篇文章,它使用了函数cv2.phase. 在此之后,角度被硬编码为特定颜色,具体取决于函数返回的度数。我的问题是这个函数为我返回的值在 0 到 90 度的范围内。因此,我得到的图像仅由红色和青色组成。

我的代码如下:

# where gray_blur is a grayscale image of dimension 512 by 512

# 3x3 sobel filters for edge detection
sobel_x = np.array([[ -1, 0, 1], 
                   [ -2, 0, 2], 
                   [ -1, 0, 1]])


sobel_y = np.array([[ -1, -2, -1], 
                   [ 0, 0, 0], 
                   [ 1, 2, 1]])


# Filter the blurred grayscale images using filter2D

filtered_blurred_x = cv2.filter2D(gray_blur, -1, sobel_x)  
filtered_blurred_y = cv2.filter2D(gray_blur, -1, sobel_y)

# …
Run Code Online (Sandbox Code Playgroud)

python opencv

5
推荐指数
2
解决办法
4003
查看次数

opencv - 从canny计算非方向性边缘

任何人都可以帮助我如何使用opencv cannyedge检测计算非定向边缘的数量?我有一个来自opencv的cannyEdge图像,我希望有一个基于边缘方向的直方图,我可以计算它的方向和非方向边数.

opencv edge-detection

3
推荐指数
1
解决办法
9292
查看次数

标签 统计

opencv ×2

edge-detection ×1

python ×1