-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors_utils.py
32 lines (29 loc) · 894 Bytes
/
colors_utils.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
#!/usr/bin/env python
import cv2
def removeGreen(image):
# convert to HSV
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
#lower_val = (36, 25, 25)
lower_val = (18, 0, 15)
upper_val = (70,255,255)
mask = cv2.inRange(hsv, lower_val, upper_val)
res = cv2.bitwise_and(image,image, mask= mask)
diff_img = image - res
return
def removeWhiteLight(image):
# convert to HSV
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
lower_val = (36, 25, 25)
upper_val = (71,255,255)
mask = cv2.inRange(hsv, lower_val, upper_val)
res = cv2.bitwise_and(image,image, mask= mask)
diff_img = image - res
return
def onlyOrange(hsv):
# convert to HSV
lower_val = (36, 25, 25)
upper_val = (71,255,255)
mask = cv2.inRange(hsv,(4, 133, 29), (24, 196, 216) )
res = cv2.bitwise_not(hsv,hsv, mask= mask)
diff_img = hsv - res
return