Python图像处理:优选PIL或任何相关模块中的角点检测所需的帮助

Voo*_*d92 7 python image-processing python-imaging-library

我是图像处理的新手并且必须对此图像进行角点检测: 在此输入图像描述

在此图像中,我需要提取每个线段的起点和终点或角点的坐标.这只是我项目中的一小部分,因为我没有图像处理经验,所以我坚持这一点.

Ste*_*alt 27

这是一个使用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()
Run Code Online (Sandbox Code Playgroud)

线段的角落