Reputation: 11
I am developing a book spine detection solution. For that I am trying to crop the image using the hough lines detected. However I am stuck at this phase. Here's the code which I am using to detect the book spines:
image = skimage.io.imread(fname='img.jpeg', as_gray=True)
edges = skimage.feature.canny(image=image,sigma=1.2,)
tested_angles = np.linspace(-np.pi/18, np.pi/18, 20)
h, theta, d = hough_line(edges, tested_angles)
for _, angle, dist in zip(*hough_line_peaks(h, theta, d)):
y0 = (dist - 0 * np.cos(angle)) / np.sin(angle)
y1 = (dist - image.shape[1] * np.cos(angle)) / np.sin(angle)
ax.plot((0, image.shape[1]), (y0, y1), '-r')
I am happy with the hough transformation, however I am not able to figure out how to use this output to crop the image in between the houghlines detected. The confusing bit is how can I convert the y0
, y1
into x,y
coordinates that I can use to crop the image. I am very new to image processing, any help would be highly appreciated.
Thank You
Upvotes: 1
Views: 155