-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencv3.py
43 lines (29 loc) · 1.06 KB
/
opencv3.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
#!/usr/bin/env python3
import numpy as np
import cv2
image_name = "tree"
color_image = cv2.imread("images/tree.jpg",cv2.IMREAD_COLOR)
cv2.imshow("Original Image",color_image)
cv2.moveWindow("Original Image",0,0)
print(color_image.shape)
height,width,channels = color_image.shape
blue,green,red = cv2.split(color_image)
cv2.imshow("Blue Channel",blue)
cv2.moveWindow("Blue Channel",0,height)
cv2.imshow("Red Channel",red)
cv2.moveWindow("Red Channel",0,height)
cv2.imshow("Greeen Channel",green)
cv2.moveWindow("Green Channel",0,height)
# Hue: indicates the type of color that we see in a 360 degree format.
# Saturation: an indication of how saturated an individual color is
# Value: indicates how luminous the channel is.
hsv = cv2.cvtColor(color_image, cv2.COLOR_BGR2HSV)
h,s,v = cv2.split(hsv)
hsv_image = np.concatenate((h,s,v),axis=1)
cv2.imshow("Hue, Saturation, Value Image",hsv_image)
cv2.imshow("HSV Image",hsv)
gray_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2GRAY)
cv2.imshow("Gray Image ",gray_image)
print(gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()