python 改变数组元素值
import numpy as npfrom keras import backendfrom PIL import Imagea = np.array([0,255,255,0,255,0,0,255,0,0])print(a)print(a.shape)b = np.array([0,255,0,0,255,0,0,255,0,0])c = a.flatten()d = a.flatten()
·
import numpy as np
from keras import backend
from PIL import Image
a = np.array([0,255,255,0,255,0,0,255,0,0])
print(a)
print(a.shape)
b = np.array([0,255,0,0,255,0,0,255,0,0])
c = a.flatten()
d = a.flatten()
print(c.shape)
print(c)
#方法一:
b[b==255]=1
# print(b)
#方法二:
for i, ele in enumerate(a):
if ele == 255:
a[i] = 1
print(c)
print(a)
print(b)
简单记录一下,在计算MIOU的时候,像素为二值像素,像素值为255的标签为第一类,在混淆矩阵的时候,需要将255像素改成1像素,和预测标签进行计算对角线上的分类正确的像素点
更多推荐
已为社区贡献1条内容
所有评论(0)