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

现在,我希望计数图像中的边缘,以获得一个数字。
有人能帮忙吗?
这是显示图像的代码:
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):
# 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因此,从图像的边缘检测,我想计数的边缘数目。我真的不知道该怎么做,所以任何帮助都会很好!
发布于 2019-01-26 14:46:42
您可以只使用连接组件的数量。
但是,任何边缘数量的度量都会非常糟糕,特别是在纹理图像中,因为边缘检测是一个不适定的问题,并且根据噪声级别和检测器设置,您可以为同一场景获得非常不同的结果。
就我个人而言,我永远不会使用这个参数。
https://stackoverflow.com/questions/54327285
复制相似问题