Coder Social home page Coder Social logo

hemapriya-2004 / edge-linking-using-hough-transform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from etjabajasphin/edge-linking-using-hough-transform

0.0 0.0 0.0 439 KB

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 100.00%

edge-linking-using-hough-transform's Introduction

Edge-Linking-using-Hough-Transform

Aim:

To write a Python program to detect the lines using Hough Transform.

Software Required:

Anaconda - Python 3.7

Algorithm:

Step1:

Import the required modules.

Step2:

Import the image to operate on.

Step3:

Convert the imported image from BGR to GRAYSCALE.

Step4:

Find the edges using canny edge detector and display the image.

Step5:

Detect the points that form a line using hough transform.

Step6:

Draw the lines on the image

Step7:

Display the output

Step8:

End the program.

Program:


# Read image and convert it to grayscale image



import cv2
import matplotlib.pyplot as plt
import numpy as np
image = cv2.imread("suduko.webp")
grayImage = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
plt.imshow(grayImage)
cv2.imshow("Original Image",image)
cv2.imshow("Gray Image",grayImage)


# Find the edges in the image using canny detector and display


import cv2
import matplotlib.pyplot as plt
import numpy as np
image = cv2.imread("sudo.png")
grayImage = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
plt.imshow(grayImage,'gray')
cv2.imshow("Original Image",image)
cv2.imshow("Gray Image",grayImage)





# Detect points that form a line using HoughLinesP
lines = cv2.HoughLinesP(cannyEdges,1,np.pi/180,threshold=80,minLineLength = 50,maxLineGap = 250)


# Draw lines on the image
for line in lines:
x1, y1, x2, y2 = line [0]
cv2.line(image,(x1, y1),(x2, y2),(255, 0, 0),3)


# Display the result

plt.title("Hough Transform")
plt.imshow(image,'gray')
plt.show()



Output

Input image and grayscale image

input image:

output

grayscale image:

output

Canny Edge detector output

output

Display the result of Hough transform

output

Result:

Thus the program is written with python and OpenCV to detect lines using Hough transform.

edge-linking-using-hough-transform's People

Contributors

etjabajasphin avatar hemapriya-2004 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.