最近在嘗試將瑕疵語意分割結果影像進行二值化的時候發現二值化后的影像為純黑,請問大佬們這是啥回事?
原圖:

轉換后圖片:

代碼:
'''
影像二值化
'''
from PIL import Image
img = Image.open(r"data\test\picture\1.png")
#模式L表示為灰色影像,它的像素用8個bit表示,0表示黑,255表示白,其他數字表示不同灰度
Img = img.convert('L')
Img.save("test1.png")
#自定義灰度界限,大于這個值為黑色,小于這個值為白色
threshould = 200
table = []
for i in range(256):
if i < threshould:
table.append(0)
else:
table.append(1)
#將圖片二值化
result = img.point(table, '1')
result.save("test2.png")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/274910.html
下一篇:不懂,哎(>﹏<)
