import numpy as np
x = [[0.299, 0.587, 0.114],[0.147, -0.289, 0.436],[0.615, -0.515, -0.1]]
rgb = [1,2,3]
x = np.matrix(x)
yst = x.dot(rgb)
编辑:
要转换完整图像,必须执行以下操作:
test_img=np.ones((32,32,3))
x = [[0.299, 0.587, 0.114],[0.147, -0.289, 0.436],[0.615, -0.515, -0.1]]
x = np.array(x)
yst_img = []
for i in range(len(test_img)):
yst_img.append([])
for rgb in test_img[i]:
yst_img[i].append(x.dot(rgb))
yst_img = np.array(yst_img) #in case you want your data as an array
您可以将转换定义为矩阵,并使用矩阵乘法进行乘法:
编辑:
要转换完整图像,必须执行以下操作:
使用
numpy
可以.array()
.dot(vector)
相关问题 更多 >
编程相关推荐