Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2afe21c

Browse files
Merge pull request avinashkranjan#610 from ShubhamGupta577/Edge-Detection-Using-OpenCV
Edge detection using open cv
2 parents d2535d3 + 29acda6 commit 2afe21c

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

‎Edge Detection/Edge_Detection.ipynb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"name": "Edge Detection.ipynb",
7+
"provenance": []
8+
},
9+
"kernelspec": {
10+
"name": "python3",
11+
"display_name": "Python 3"
12+
}
13+
},
14+
"cells": [
15+
{
16+
"cell_type": "code",
17+
"metadata": {
18+
"id": "YHDlTX5nCuJH"
19+
},
20+
"source": [
21+
"'''\r\n",
22+
" For uploading the picture in colab follow the given steps\r\n",
23+
" 1. Click on the folder icon given in the left side of colab window\r\n",
24+
" 2. Click on the upload icon.\r\n",
25+
" 3. Select the image you want to upload.\r\n",
26+
" 4. Right click on the uploaded image, click on \"copy path\"\r\n",
27+
" 5. Paste it as a input when path will be asked \r\n",
28+
"'''\r\n",
29+
"#Importing openCV library\r\n",
30+
"import cv2 as cv\r\n",
31+
"#For printing the image in google colab\r\n",
32+
"from google.colab.patches import cv2_imshow\r\n",
33+
"\r\n",
34+
"path=input(\"Enter the path of uploaded image\")\r\n",
35+
"img=cv.imread(path)\r\n",
36+
"#Printing the original image\r\n",
37+
"cv2_imshow(img)\r\n",
38+
"#Reducing the noise from the image\r\n",
39+
"gray=cv.cvtColor(img,cv.COLOR_RGB2GRAY)\r\n",
40+
"\r\n",
41+
"#Using Canny algorithm to detect the edges of the image\r\n",
42+
"#You can vary the quality by changing 2nd and 3rd parameter in following function\r\n",
43+
"final=cv.Canny(gray,100,200)\r\n",
44+
"cv2_imshow(final)"
45+
],
46+
"execution_count": null,
47+
"outputs": []
48+
}
49+
]
50+
}

‎Edge Detection/Edge_Detection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'''
2+
For using this Script you need to install OpenCV in your machine
3+
'''
4+
#Importing openCV library
5+
import cv2 as cv
6+
7+
#Taking path of input from the user
8+
path=input("Enter the path of uploaded image: ")
9+
img=cv.imread(path)
10+
img=cv.resize(img,(640,640)) #resizing the image
11+
12+
#Printing the original image
13+
cv.imshow('Original',img)
14+
#Reducing the noise from the image
15+
gray=cv.cvtColor(img,cv.COLOR_RGB2GRAY)
16+
17+
#Using Canny algorithm to detect the edges of the image
18+
final=cv.Canny(gray,100,200)
19+
print('Number of edges'+ '=' +str(len(final))) #printing Number of edges
20+
cv.imshow('Final',final)
21+
cv.waitKey(0)
22+
cv.destroyAllWindows()

‎Edge Detection/Readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## **Edge Detection of a image**
2+
3+
This script uses `OpenCV` for taking input and output for the image. In this we are using he `Canny algorithm` for the detection of the edge
4+
## How to use it
5+
6+
### You can use this in two ways
7+
* If your machine has any python intrepretor than you can go for [**Edge_Detection.py**](https://github.com/ShubhamGupta577/Amazing-Python-Scripts/blob/Edge-Detection-Using-OpenCV/Edge%20Detection/Edge_Detection.py)
8+
* For these you need to install **OpenCV** in your machine.
9+
* Another way is to use the [**Google Colab file**](https://github.com/ShubhamGupta577/Amazing-Python-Scripts/blob/Edge-Detection-Using-OpenCV/Edge%20Detection/Edge_Detection.ipynb) which will be excecute on a cloud.
10+
11+
## Technologies used
12+
* **Python**
13+
* **OpenCV**
14+
* **Google Colab**
15+
## Sample Input/Output
16+
<img src ="https://github.com/ShubhamGupta577/Amazing-Python-Scripts/blob/Edge-Detection-Using-OpenCV/Edge%20Detection/Sample_Input.jpg" width=400/> <img src ="https://github.com/ShubhamGupta577/Amazing-Python-Scripts/blob/Edge-Detection-Using-OpenCV/Edge%20Detection/Sample_Output.png" width=400/>
17+
18+
19+
## Author
20+
[Shubham Gupta](https://github.com/ShubhamGupta577)

‎Edge Detection/Sample_Input.jpg

91.2 KB
Loading[フレーム]

‎Edge Detection/Sample_Output.png

13.2 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /