I'm new to image processing and got to do corner detection for this image:
In this image, I need to extract the starting and end points of each line segment or the coordinates of the corners. This is just a small part in my project and I'm stuck on this because I've no experience in image processing.
解决方案
Here's a solution, using 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()