import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
import scipy.io as io
img = np.zeros((1536,2048),np.uint8)
import cv2
# 读取文本标注文件
annot = io.loadmat('./file/poly_gt_img179.mat')
multy_polys = []
for cell in annot['polygt']:
x = cell[1][0]
y = cell[3][0]
pts = np.stack([x,y]).T.astype(np.int32)
multy_polys.append(pts)
cv2.fillpoly(img, multy_polys,color=(255,255,255))
plt.imshow(img)
plt.show()
其中 annot['poltygt']为:
原图为:
输出的图像为: