import os
import cv2
from tqdm import tqdm
import numpy as np
img_path = r'/media/wagnchogn/data_16t/segment data/Gleason 2019/crop/mask'
save_path = r'/media/wagnchogn/data_16t/segment data/Gleason 2019/crop/masks'
mask_files = os.listdir(img_path)
for mask_file in tqdm(mask_files):
mask_path = os.path.join(img_path, mask_file)
mask_array = cv2.imread(mask_path, cv2.IMREAD_UNCHANGED)
mask_array[mask_array != 0] = 255
cv2.imwrite(os.path.join(save_path, mask_file), mask_array)