import cv2
import numpy as np
import os
import random
from PIL import Image
import matplotlib.pyplot as plt
# https://blog.csdn.net/qq_44886601/article/details/135764589
# 将mask绘制在原图
def draw_image(im, ms, brg, opacity):
image_mask = im.copy()
contours, _ = cv2.findContours(ms, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) # 查找轮廓
image_mask = cv2.drawContours(image_mask, contours, -1, (0, 255, 0), 2) # 绘制边界
image_mask = cv2.fillPoly(image_mask, contours, color=brg) # 填充
img_bgr = cv2.addWeighted(im, opacity, image_mask, 1 - opacity, 0)
return im, ms, img_bgr
def main(imagePath, labelPath, bgr, opacity):
image = np.array(Image.open(imagePath).convert('RGB'))
label = np.array(Image.open(labelPath).convert('L'))
a, b, c = draw_image(image, label, bgr, opacity)
plt.figure(figsize=(12, 8))
for index, i in enumerate((a, b, c)):
plt.subplot(1, 3, index + 1)
plt.imshow(i)
plt.savefig('./result.png')
# plt.show()
if __name__ == '__main__':
root = './data/train/images'
images_path = [os.path.join(root, i) for i in os.listdir(root)]
r = random.randint(0, len(images_path) - 1)
img_path = images_path[r] # 随机取出一张图片
mask_path = img_path.replace('images', 'masks')
mask_path =mask_path.replace('.jpg', '.png')
# opacity 越小,掩膜效果越深
main(imagePath=img_path, labelPath=mask_path, bgr=(0, 0, 255), opacity=0.5)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
项目包含DUT-OMRON图像数据集(二值图像分割),文件以文件夹格式储存,可直接用作图像分割数据集,无需额外处理。 数据集总大小:113MB 数据集介绍:分为训练集、测试集 训练集:images图片目录+masks模板目录,4135张图片和4135个对应的mask图片 测试集:images图片目录+masks模板目录,1033张图片和1033个对应的mask图片 除此之外,包含一个图像分割的可视化脚本,随机提取一张图片,将其原始图片、GT图像、GT在原图蒙板的图像展示,并保存在当前目录下
资源推荐
资源详情
资源评论
收起资源包目录
深度学习之图像分割数据集:DUT-OMRON图像分割数据集(二值图像分割) (2000个子文件)
sun_ayjfvfkfzpzpdzrl.png 4KB
sun_alxzuqeuhlfxmyft.png 3KB
sun_ahtvpvsexgxujtel.png 3KB
sun_addrjgltpljctvkb.png 3KB
sun_bchwnkpdyxlduidz.png 3KB
sun_actpesihwcwcymoi.png 3KB
sun_aeorarujsapqmkkw.png 3KB
sun_bhaczmbnveekqjyp.png 3KB
sun_aymezeaiisjbbpkl.png 3KB
sun_aygiaihnfqcrehqh.png 3KB
sun_azfbhcxkxctjcqyg.png 3KB
sun_amlrkpnfruuenksp.png 3KB
sun_amxxltxsnzbjosmk.png 3KB
sun_anzoyntpuzkyzgyn.png 3KB
sun_asvboytpyzmlptxv.png 3KB
sun_apocxgvoetnmvmmx.png 3KB
sun_bcgwdvwatanefeec.png 3KB
sun_aiptpsivadrdctiv.png 3KB
sun_aaeuxbehhiulglhu.png 3KB
sun_adfykdhvfyfgoovt.png 2KB
sun_absizbuqygehvgpu.png 2KB
sun_annfkqahmofdfwix.png 2KB
sun_afuaatjqrfgxqrin.png 2KB
sun_bgxakxhkaswgkiqa.png 2KB
sun_aeplbxttmoigmroa.png 2KB
sun_aaohmceweijvtinz.png 2KB
sun_akvzsjmosstuesqm.png 2KB
sun_bcucyxhdgyiujpfa.png 2KB
sun_bwjpnkiwovgfqdvw.png 2KB
sun_alfjlqacifebgdmm.png 2KB
sun_abfmglifjheyyvau.png 2KB
sun_atnpuxdlncqwiqxg.png 2KB
sun_bqdokbdkliwpfdtq.png 2KB
sun_bipcbyyokunfbaxw.png 2KB
sun_bbslhphpiejdjmpz.png 2KB
sun_btbexpsjhutpaiwq.png 2KB
sun_acisdukrvqigarjr.png 2KB
sun_aawzmvlmobsxyoqb.png 2KB
sun_abzslnasytpohfln.png 2KB
sun_bpkeqvuqvhipxuur.png 2KB
sun_awgrlxjpohtzixbw.png 2KB
sun_adoedkspaeyehqwc.png 2KB
sun_bauueuhhvklldjik.png 2KB
sun_agzscfojbhgrdjfq.png 2KB
sun_advhywkghkegfjrp.png 2KB
sun_bkfnmlxmelddfksa.png 2KB
sun_amswlkudbozrurti.png 2KB
sun_bkwhlasasocuraux.png 2KB
sun_akjfqwfhyotgdgkx.png 2KB
sun_buhxycihtbwpiice.png 2KB
sun_aowqwqmchmurzprz.png 2KB
sun_alwcmbmsinedkexo.png 2KB
sun_acirykhmyytbdzqc.png 2KB
sun_avufxousetiopneu.png 2KB
sun_avuzghxmskrhmjby.png 2KB
sun_aehnhsbvxbxdcuek.png 2KB
sun_agbzabamxccxumhc.png 2KB
sun_aklaangaztfivcig.png 2KB
sun_aqdwsjkirgzkggiv.png 2KB
sun_aexoqbpdgryoriwq.png 2KB
sun_aujqccaagnncnbdu.png 2KB
sun_bamunjvxvlcyagxh.png 2KB
sun_auuqrmygimuuizju.png 2KB
sun_abcenmxemcpjrbax.png 2KB
sun_abdalwpprwbflfrk.png 2KB
sun_bjrvuptgehngyuyd.png 2KB
sun_byviosfnsigdymqj.png 2KB
sun_awentnobehmvaxkp.png 2KB
sun_axqhvfcyvcxcqttc.png 2KB
sun_bfobwcwfplgxuiym.png 2KB
sun_acjrsclziatbxmpn.png 2KB
sun_afhkpkvnuiqxejrd.png 2KB
sun_bjjckdwaehmbdnir.png 2KB
sun_adgsemuxqjscdtdc.png 2KB
sun_askndeuqhmhuqeob.png 2KB
sun_ajeznvlilojwvisw.png 2KB
sun_aenfxcmcyjaoeeme.png 2KB
sun_accivvhbddemnscz.png 2KB
sun_brpgjfgwlrnyijtw.png 2KB
sun_apddspnzzaaqrphl.png 2KB
sun_bmxqqpzpuhvawwms.png 2KB
sun_bgcbuglaxhouzcnc.png 2KB
sun_avrohyfvnhdfsbpv.png 2KB
sun_aokredbbditgkfqp.png 2KB
sun_acgxkjtmaaqvjadb.png 2KB
sun_ampfgvtsidubivcz.png 2KB
sun_bcnytreyqaezavlx.png 2KB
sun_arebfbeocihdehdc.png 2KB
sun_azdvbhfueegligps.png 2KB
sun_alolzsicfeumpstf.png 2KB
sun_abnepvzvycqjjczs.png 2KB
sun_byvglypwutrmvtcv.png 2KB
sun_agxfmguttxrhovid.png 2KB
sun_aayhizqmlxtbhnmn.png 2KB
sun_afkxyeukzjcshcrz.png 2KB
sun_aebixnklcvbqsxfr.png 2KB
sun_btebrtrymeikdcji.png 2KB
sun_beyntnwppzfmbkiq.png 2KB
sun_amidnhjbgtwskaaf.png 2KB
sun_aliadxubdmitkpcm.png 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
听风吹等浪起
- 粉丝: 1w+
- 资源: 1152
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功