Last active
October 17, 2019 15:01
-
-
Save zhunhung/0e33cdb2d2d21a17eb5dfb82b680437c to your computer and use it in GitHub Desktop.
Example of using OpenCV colour segmentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color = [211, 227, 191] | |
# Convert our image from BGR to HSV | |
hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) | |
limit = np.uint8([[color]]) | |
# Convert our color of choice to HSV as well | |
limit = cv2.cvtColor(limit,cv2.COLOR_BGR2HSV)[0][0] | |
mask = cv2.inRange(hsv_img, limit, limit) | |
# Filter for the colour | |
res = cv2.bitwise_and(img,img, mask= mask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment