利用genjson和WSI切片生成训练集与对应的mask
import cv2
import numpy as np
import json
import os
import glob
from PIL import Image
img = np.zeros((1080, 1920), np.uint8)
def gen_coordinate(path_to_geojson:str)->list :
with open(path_to_geojson,encoding="utf-8") as f:
a = json.load(f,encoding="utf-8")
coordinate=[]
for i in range(len(a['features'])):
current = []
label = 0
if a['features'][0]['properties']['classification']['name'] =='低级别':
label = 1
current.append(i)
current.append(label)
current.append(a['features']<