GithubHelp home page GithubHelp logo

vaishnavi-saravanan / edge-linking-using-hough-transformm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swedha333/edge-linking-using-hough-transformm

0.0 0.0 0.0 16 KB

License: GNU General Public License v3.0

Python 100.00%

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

Edge-Linking-using-Hough-Transformm

Aim:

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

Software Required:

Anaconda - Python 3.7

Algorithm:

Step1:

Import all the necessary modules for the program.

Step2:

Load a image using imread() from cv2 module.

Step3:

Convert the image to grayscale.

Step4:

Using Canny operator from cv2,detect the edges of the image.

Step5:

Using the HoughLinesP(),detect line co-ordinates for every points in the images.Using For loop,draw the lines on the found co-ordinates.Display the image.

Program:

Developed By: VAISHNAVI S
Register No: 212222230165
# Read image and convert it to grayscale image
import cv2
import numpy as np
r=cv2.imread('catt.jpg',-1)
gray=cv2.cvtColor(r,cv2.COLOR_BGR2GRAY)
img = cv2.GaussianBlur(gray,(3,3),0)
cv2.imshow('origianl',r)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imshow('gray',gray)
cv2.waitKey(0)
cv2.destroyAllWindows()


# Find the edges in the image using canny detector and display
canny_edges = cv2.Canny(img, 50, 120)
cv2.imshow('canny',canny_edges)
cv2.waitKey(0)
cv2.destroyAllWindows()


# Detect points that form a line using HoughLinesP
lines =cv2.HoughLinesP(canny_edges, 1, np.pi/180,threshold = 15, minLineLength =5 ,
maxLineGap = 7)



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



# Display the result
cv2.imshow('hough_detected',r)
cv2.waitKey(0)
cv2.destroyAllWindows()

Output

Input image and grayscale image

272628313-439083fb-e2a7-40b9-ae23-c2168c8e8440

Canny Edge detector output

272628291-ec7e0880-d7fa-446b-ae52-7e7e0bce53c0

Display the result of the Hough transform

272628305-5744c6ec-2e49-4f6a-aeb8-6d66e47b3931

Result:

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

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

Contributors

vaishnavi-saravanan avatar swedha333 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.