分割任务之后总是想检查下img和mask是否匹配,我们需要把两张图放在一起看,下面就是操作。
img = Image.open(file)
masked_image = np.array(img).copy()
# 把img和mask合并
colors = random_colors(10)
color = colors[6]
masked_image = apply_mask(masked_image, labels_arr, color)
masked_image_save = Image.fromarray(

本文介绍了在图像处理任务中如何检查并合并img和mask的方法。通过使用PIL库打开图片,将img和mask结合,并利用random_colors函数生成随机颜色,apply_mask函数将mask应用到图片上,最终保存合并后的图像。该过程对于确保图像分割任务的准确性至关重要。
最低0.47元/天 解锁文章
3627





