Python-anaconda Practice candy operator for edge extraction, and then use Hough Transform to detect line edges

Source: Internet
Author: User

IMG: The image to be detected.

Threshold: Threshold value, first entry, default = 10

Line_length: The shortest line length detected, default is 50

Line_gap: The maximum gap between lines. Increase this value to merge broken lines. Default is 10

Return:

Lines: A list of lines, formatted as ((x0, y0), (x1, y0)), indicating the start and end points.

Below, we use the canny operator to extract the edges and then detect which edges are straight lines?

Import Skimage.transform as Stimport Matplotlib.pyplot as Pltfrom skimage import data,feature# use probabilistic Hough Trans Form.image = Data.camera () edges = Feature.canny (image, sigma=2, low_threshold=1, high_threshold=25) lines = St.probabilistic_hough_line (edges, threshold=10, line_length=5,line_gap=3) # Create a display window. Fig, (ax0, ax1, ax2) = Plt.subplots (1, 3, figsize= (6)) Plt.tight_layout () #显示原图像ax0. Imshow (image, Plt.cm.gray) ax0.set_title (' Input image ') ax0.set_ Axis_off () #显示canny边缘ax1. Imshow (edges, Plt.cm.gray) ax1.set_title (' Canny edges ') Ax1.set_axis_off () # Plot all the straight lines with plot ax2.imshow (edges * 0) for the line in lines: p0, p1 = ((Ax2.plot], p0[0])    , P1[0, C Ol2 = Image.shapeax2.axis ((0, col2, row2, 0)) Ax2.set_title (' Probabilistic Hough ') Ax2.set_axis_off () plt.show ()

Python-anaconda Practice candy operator for edge extraction, and then use Hough Transform to detect line edges

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.