-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_basic.py
More file actions
40 lines (31 loc) · 943 Bytes
/
Copy path4_basic.py
File metadata and controls
40 lines (31 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2 as cv
img = cv.imread("Photos/park.jpg")
cv.imshow("Park", img)
# Converting to grayscale
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow("Gray", gray)
# Blur
blur = cv.GaussianBlur(img, (3, 3), cv.BORDER_DEFAULT)
cv.imshow("Blur", blur)
blur2 = cv.GaussianBlur(img, (7, 7), cv.BORDER_DEFAULT)
cv.imshow("Blur2", blur2)
# Edge Cascade
canny = cv.Canny(img, 125, 175)
cv.imshow("Canny Edges", canny)
canny = cv.Canny(img, 55, 125)
cv.imshow("Canny Edges 2", canny)
canny = cv.Canny(blur, 125, 175)
cv.imshow("Canny Edges Blur", canny)
# Dilating the image
dilated = cv.dilate(canny, (3, 3), iterations = 1)
cv.imshow("Dilated", dilated)
# Eroding
eroded = cv.erode(dilated, (3, 3), iterations = 1)
cv.imshow("Eroded", eroded)
# Resize
resized = cv.resize(img, (500, 500), interpolation = cv.INTER_CUBIC)
cv.imshow("Resized", resized)
# Cropping
cropped = img[50:200, 200:400]
cv.imshow("Cropped", cropped)
cv.waitKey(0)