forked from imhighoncoffee/sosc_cv101
-
Notifications
You must be signed in to change notification settings - Fork 1
/
intro_to_ip.py
75 lines (53 loc) · 1.7 KB
/
intro_to_ip.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import cv2
import imutils
image = cv2.imread("boruto.jpg")
#translation
shifted = imutils.translate(image, 0, 100)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
shifted = imutils.translate(image, 100, 0)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
shifted = imutils.translate(image, 100, 100)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
cv2.destroyAllWindows()
#translation
shifted = imutils.translate(image, 0, -100)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
shifted = imutils.translate(image, -100, 0)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
shifted = imutils.translate(image, -100, -100)
cv2.imshow("Shifted Down", shifted)
cv2.waitKey(0)
cv2.destroyAllWindows()
#rotation
#syntax: imutils.rotate(image_name,angle)
rotated = imutils.rotate(image, 180)
cv2.imshow("Rotated by 180 Degrees", rotated)
cv2.waitKey(0)
rotated = imutils.rotate(image, 45)
cv2.imshow("Rotated by 180 Degrees", rotated)
cv2.waitKey(0)
#resizing
#syntax: imutils.resize(image,height/width=pixel_length)
resized = imutils.resize(image, width = 100)
cv2.imshow("Resized via Function", resized)
cv2.waitKey(0)
resized = imutils.resize(image, height = 1000)
cv2.imshow("Resized via Function", resized)
cv2.waitKey(0)
cv2.destroyAllWindows()
#flipping
cv2.imshow("Original", image)
flipped = cv2.flip(image, 1)
cv2.imshow("Flipped Horizontally", flipped)
flipped = cv2.flip(image, 0)
cv2.imshow("Flipped Vertically", flipped)
flipped = cv2.flip(image, -1)
cv2.imshow("Flipped Horizontally & Vertically", flipped)
cv2.waitKey(0)
cv2.destroyAllWindows()
####################################################################################################################################################