进行TransColor转换
先np.zeros构造彩色矩阵
然后每个像素按照经验公式进行转换!
def TransColor(image): rows = image.shape[0] cols = image.shape[1] print(rows, cols) Color = np.zeros((rows, cols, 3), np.uint8) 使用zeros构造彩色矩阵 这种方法很好 很常用
for i in range(rows): for j in range(cols): r = SetcolorR(image[i,j]) g = SetcolorG(image[i,j]) b = SetcolorB(image[i,j]) Color[i, j, 0] = r Color[i, j, 1] = g Color[i, j, 2] = b return Color