• 大小: 463B
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-13
  • 语言: Python
  • 标签: labelme  

资源简介

使用python语言将16位图像转换为8位图像,用于labelme标记的MASK_RCNN

资源截图

代码片段和文件信息

from PIL import Image
import numpy as np
import math
import os

path = ‘C:\\Users\\Administrator\\Desktop\\old_label\\‘
newpath = ‘C:\\Users\\Administrator\\Desktop\\mask\\‘


def toeight():
    filelist = os.listdir(path)  # 该文件夹下所有的文件(包括文件夹)
    for file in filelist:
        whole_path = os.path.join(path file)
        img = Image.open(whole_path)  # 打开图片img = Image.open(dir)#打开图片
        img = np.array(img)
        # img = Image.fromarray(np.uint8(img / float(math.pow(2 16) - 1) * 255))
        img = Image.fromarray(np.uint8(img))
        img.save(newpath + file)


toeight()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        656  2018-04-08 15:02  transform2uint8.py

----------- ---------  ---------- -----  ----

                  656                    1


评论

共有 条评论