This script helps to create binary mask files from XML based on the color of annotation. If you want to change the color of annotation, refer to another code in my repository for XML modification.
xml_path= '.../Test_xml_path/'
file_path = r".../Test_svsfiles/"
mask_output =r".../Mak_out"
dict_mask =get_points_base(w,"yellow",custom_colors=[]) # selected "yellow" color to extract mask of it
import openslide
from WSI_handling import wsi
import os
import numpy as np
import matplotlib.pyplot as plt
import xml.etree.ElementTree as ET
import numpy as np
from pathlib import Path
from shapely.geometry import Polygon, MultiPolygon
from shapely.strtree import STRtree
import shapely.affinity
import rasterio.features
import cv2
from tqdm import *
from skimage.util import view_as_blocks
import gc