我试图用一个方程式来重建HDR图像,在这个方程式中,我必须对每个i值的分子和分母中的j值(0-15)求和。有没有更快的方法?使用np.sum
g是一个长度为255的一维数组,用于重新映射所有像素值
lEks是15幅图像的对数曝光时间
Z是一个大小为[95488,15]的数组,第一个维度是像素索引,第二个维度是图像编号
def genHDR(Z,g,lEks):
Zi, Zj = Z.shape #[95488, 15]
HDRimage= np.zeros(Zi)
for i in range(Zi):
numerator = 0
denominator = 0
for j in range(Zj):
numerator +=(Z[i,j])*(g[Z[i,j]] - lEks[j])
denominator +=(Z[i,j])
HDRimage[i] = numerator/denominator
return HDRimage
@Dillman击败了我。也许你仍然可以使用下面的方法来构造它。我喜欢分步思考
输出:
最好的方法可能是使用np.Array.sum(axis=1)。假设g(Z[i,j])调用是有效的。实际上,您甚至不需要任何循环:
相关问题 更多 >
编程相关推荐