1
私は、この画像の各コンポーネントを選択します:実際にOpenCVのPythonのconnectedComponents選択コンポーネント
、一人ひとりの三角形、そのラベルによります。私はどのように把握していない。 私はこのコードを持っている:
#!/usr/bin/python
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)
invBwMesh = cv2.bitwise_not(imBw)
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]
labels = labels + 1
b = (labels == 1)
cv2.imwrite('tst.jpg',labels[b])
をしかし、画像が黒completyです:S はどうもありがとうございました。