-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintro.py
More file actions
28 lines (22 loc) · 785 Bytes
/
intro.py
File metadata and controls
28 lines (22 loc) · 785 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
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('img/new.jpg', cv2.IMREAD_GRAYSCALE) #grayscale is much more good for image analysis
#IMREAD_COLOR = 1
#IMREAD_UNCHANGED = -1
#IMREAD_GRAYSCALE = 0
cv2.imshow('new_image', img)
#cv2.waitKey(0)
#cv2.destroyAllWindows()
#cv2.destroyWindow(windowname)
# plt.imshow(img, cmap='gray', interpolation='bicubic')
# plt.plot([50,100], [80,100], 'c', linewidth=5)
# plt.show()
cv2.imwrite('output/grayone.jpg', img)
# k = cv2.waitKey(0) # for 32-bit machines
k = cv2.waitKey(0) & 0xFF # for 64-bit machines
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()
elif k == ord('s'): # wait for 's' key to save and exit
cv2.imwrite('output/newgray.png',img)
cv2.destroyAllWindows()