資源簡介
使用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
評論
共有 條評論