Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imMeshLayer = cv2.imread('testLayer6_.png', -1)
- imMesh = cv2.imread('new_refined2__DXF.png', -1)
- """
- binary conversions
- """
- imGrayMshLayer = cv2.cvtColor(imMeshLayer, cv2.COLOR_BGR2GRAY)
- (thresh, imMeshly_bw) = cv2.threshold(imGrayMshLayer, 128, 255,
- cv2.THRESH_BINARY | cv2.THRESH_OTSU)
- imGrayMsh1 = cv2.cvtColor(imMesh, cv2.COLOR_BGR2GRAY)
- (thresh, imMesh_bw1) = cv2.threshold(imGrayMsh1, 128, 255,
- cv2.THRESH_BINARY | cv2.THRESH_OTSU)
- # connected components
- invBwMesh = cv2.bitwise_not(imMesh_bw1)
- cv2.imwrite('invMehs.png', invBwMesh)
- """
- connect components
- """
- connectivity = 4
- # Perform the operation
- output = cv2.connectedComponentsWithStats(imMesh_bw1, connectivity, cv2.CV_32S)
- # Get the results
- # The first cell is the number of labels
- num_labels = output[0]
- # The second cell is the label matrix
- labels = output[1]
- # The third cell is the stat matrix
- stats = output[2]
- # The fourth cell is the centroid matrix
- centroids = output[3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement