首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何计算应用Canny边缘检测后的边缘数?

如何计算应用Canny边缘检测后的边缘数?
EN

Stack Overflow用户
提问于 2019-01-23 12:27:56
回答 1查看 1.7K关注 0票数 1

我有一个图像,我应用feature.canny算法来获取图像的边缘。

现在,我希望计数图像中的边缘,以获得一个数字。

有人能帮忙吗?

这是显示图像的代码:

代码语言:javascript
复制
def canny_detection(image):

    # Convert to grayscale and convert the image to float
    RGB = img_as_float(color.rgb2gray(image))

    # Apply Canny edge detection algorithm
    edge_canny = feature.canny(RGB, 2)

    # Plot results
    plt.figure(figsize=(15,5))
    plt.subplot(121)
    plt.imshow(RGB, cmap=cm.gist_gray)
    plt.title('Original image')
    plt.subplot(122)
    plt.imshow(edge_canny, cmap=cm.gist_gray)
    plt.title('Canny edge map')`

我还有一些应用Canny的代码,然后从图像中提取数组,如果这有帮助的话:

def canny_detection(image):

代码语言:javascript
复制
# Convert to grayscale and convert the image to float
RGB = img_as_float(color.rgb2gray(image))

# Apply Canny edge detection algorithm
edge_canny = feature.canny(RGB,3)
#print(edge_canny)
edge_canny = edge_canny.astype(int)
#print(edge_canny)

#Get output array
canny_arr = np.array(edge_canny)

# Flatten output array
canny_flat = canny_arr.flatten()
#print(np.count_nonzero(canny_flat))   #to see if the matrix is all zeros

return canny_flat

因此,从图像的边缘检测,我想计数的边缘数目。我真的不知道该怎么做,所以任何帮助都会很好!

EN

回答 1

Stack Overflow用户

发布于 2019-01-26 14:46:42

您可以只使用连接组件的数量。

但是,任何边缘数量的度量都会非常糟糕,特别是在纹理图像中,因为边缘检测是一个不适定的问题,并且根据噪声级别和检测器设置,您可以为同一场景获得非常不同的结果。

就我个人而言,我永远不会使用这个参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54327285

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档