怎么将labelmap二次处理为可视的图片呢?
专注路过一百年 发布于2021-02 浏览:4718 回复:2
0
收藏

分割图片,得到labelmap

根据文档说明:分割结果图片,base64编码之后的二值图像,需二次处理方能查看分割效果

怎么将labelmap二次处理为可视的图片呢?

下面是网上找到的code,但是看不懂,不知道为什么要这样转换

import cv2
import base64
import numpy as np
import os

labelmap = base64.b64decode(seg_res['labelmap']) #分割结果图片,base64编码之后的二值图像,需二次处理方能查看分割效果
nparr = np.frombuffer(labelmap, np.uint8)
labelimg = cv2.imdecode(nparr, 1)
labelimg = cv2.resize(labelimg, (width, height), interpolation=cv2.INTER_NEAREST)
new_img = np.where(labelimg == 1, 255, labelimg)
mask_name = './test.png'
# 保存分割出来的人像
cv2.imwrite(mask_name, new_img)

收藏
点赞
0
个赞
共2条回复 最后由坦约欠N78bl4Pt回复于2021-05
#12用户已被禁言回复于2021-05

https://xasgkfp.diytrade.com/
http://xasgkfp.diytrade.com/
http://xakfp.simplesite.com/
http://cdfapiao.simplesite.com/

0
#8用户已被禁言回复于2021-05

https://xasgkfp.diytrade.com

http://xasgkfp.diytrade.com

0
TOP
切换版块