forked from x4nth055/pythoncode-tutorials
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedge_detector.py
More file actions
Latest commit
21 lines (16 loc) · 496 Bytes
/
Copy pathedge_detector.py
File metadata and controls
21 lines (16 loc) · 496 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importcv2
importnumpyasnp
importmatplotlib.pyplotasplt
importsys
# read the image
image=cv2.imread(sys.argv[1])
# convert it to grayscale
gray=cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# show the grayscale image, if you want to show, uncomment 2 below lines
# plt.imshow(gray, cmap="gray")
# plt.show()
# perform the canny edge detector to detect image edges
edges=cv2.Canny(gray, threshold1=30, threshold2=100)
# show the detected edges
plt.imshow(edges, cmap="gray")
plt.show()