【发布时间】:2013-08-11 10:17:22
【问题描述】:
我正在使用 Python 中的 OpenCV 库编写一些代码。在这个过程中,我需要根据给定的另一个矩阵构造一个矩阵。现在我的代码如下所示:
for x in range(0, width):
for y in range(0, height):
if I_mat[x][y]>=0 and I_mat[x][y]<=c_low:
w_mat[x][y] = float(I_mat[x][y])/c_low
elif I_mat[x][y]>c_low and I_mat[x][y]<c_high:
w_mat[x][y] = 1
else:
w_mat[x][y] = float((255-I_mat[x][y]))/float((255-c_high))
其中,I_mat 是输入矩阵,w_mat 是我要构建的矩阵。由于输入矩阵很大,所以这个算法很慢。我想知道是否还有其他方法可以更有效地构造 w_mat。非常感谢!
(无需在 Python 中显示解决方案。)
【问题讨论】:
标签: c++ python opencv computer-vision