我是图像处理的新手,必须为此图像进行角点检测:
在这个图像中,我需要提取每条线段的起点和终点或拐角的坐标。这只是我项目中的一小部分,我一直坚持这一点,因为我没有图像处理方面的经验。
最佳答案
这是一个解决方案,使用 scikit-image :
from skimage import io, color, morphology
from scipy.signal import convolve2d
import numpy as np
import matplotlib.pyplot as plt
img = color.rgb2gray(io.imread('6EnOn.png'))
# Reduce all lines to one pixel thickness
snakes = morphology.skeletonize(img < 1)
# Find pixels with only one neighbor
corners = convolve2d(snakes, [[1, 1, 1],
[1, 0, 1],
[1, 1, 1]], mode='same') == 1
corners = corners & snakes
# Those are the start and end positions of the segments
y, x = np.where(corners)
plt.imshow(img, cmap=plt.cm.gray, interpolation='nearest')
plt.scatter(x, y)
plt.axis('off')
plt.show()
关于Python图像处理: Help needed for corner detection in preferably PIL or any relevant module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8686926/