Last active
February 8, 2022 02:49
-
-
Save MaddoxRauch/ab18934c3fb620cb938ea9570eff0ecc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import cv2 | |
def img_show_components(labels): # Shows the different marks by assigning random colors to them. | |
# Map component labels to hue val | |
label_hue = np.uint8(179*labels/np.max(labels)) | |
blank_ch = 255*np.ones_like(label_hue) | |
labeled_img = cv2.merge([label_hue, blank_ch, blank_ch]) | |
# cvt to BGR for display | |
labeled_img = cv2.cvtColor(labeled_img, cv2.COLOR_HSV2BGR) | |
# set bg label to black | |
labeled_img[label_hue == 0] = 0 | |
cv2.imshow('labeled.png', labeled_img) | |
cv2.waitKey() | |
img_show_components(markers) |
This file contains hidden or 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
Use to reveal separated components or markers in cv2 image edits. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment