We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 068f317 commit 94d33c5Copy full SHA for 94d33c5
color_detection.py
@@ -0,0 +1,26 @@
1
+import numpy as np
2
+import argparse
3
+import cv2
4
+
5
+ap = argparse.ArgumentParser()
6
+ap.add_argument("-i", "--image", required=True, help = "path to image")
7
+args = vars(ap.parse_args())
8
9
+image = cv2.imread(args["image"])
10
11
+boundaries = [
12
+ ([17, 15, 100], [50, 56, 200]),
13
+ ([86, 31, 4], [220, 88, 50]),
14
+ ([25, 146, 190], [62, 174, 250]),
15
+ ([103, 86, 65], [145, 133, 128])
16
+]
17
18
+for (lower, upper) in boundaries:
19
+ lower = np.array(lower, dtype = "uint8")
20
+ upper = np.array(upper, dtype = "uint8")
21
22
+ mask = cv2.inRange(image, lower, upper)
23
+ output = cv2.bitwise_and(image, image, mask = mask)
24
25
+ cv2.imshow("images", np.hstack([image, output]))
26
+ cv2.waitKey(0)
0 commit comments