predicted=predicteds*255
predicted.shape
>>>(300,300)
img = np.array(predicted, dtype=np.uint8)
#img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
mask = np.zeros(img.shape,dtype=np.uint8)
print(np.shape(img))
# 先利用二值化去除图片噪声
ret, thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
plt.subplot(1,2,1)
plt.imshow(thresh)
plt.subplot(1,2,2)
plt.imshow(mask)
需要画出二维图像的轮廓,发现轮廓线无法绘制上去
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cv2.drawContours(img, contours, -1, (0,0,255), 2)
# n = len(contours) # 轮廓的个数
# print(n)
# cv_contours = []
# for contour in contours:
# area = cv2.contourArea(contour)
# if area <= 800:
# cv_contours.append(contour)
# cv2.drawContours(mask,