Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # import os
- import cv2
- import numpy as np
- img = cv2.imread('invMehs.png', -1)
- imGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- ret, imBw = cv2.threshold(imGray, 250, 255, cv2.THRESH_BINARY)
- # connected components
- colorMask = np.ones(img.shape, dtype="uint8") * 255
- Mask = np.ones(imBw.shape, dtype="uint8") * 255
- connectivity = 4
- output = cv2.connectedComponentsWithStats(imBw, connectivity, cv2.CV_32S)
- num_labels = output[0]
- labels = output[1]
- stats = output[2]
- centroids = output[3]
- print(labels)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement