我有一个如下所示的工作代码,但是当我的rgbL很大时,我收到此错误:内存问题:MemoryError:无法分配形状为(4104、1048576、3)和数据类型为int32的数组
该如何解决?
sh = img.shape
img = img.reshape(-1, 3)
img[np.where(((rgbL[:,None,:]-img)==0).all(axis=2))[1]]=np.array([255,0,0])
img = img.reshape(sh)
其中img和rgbL定义为:
img:
[[20 45 40]
[ 30 45 60]
[ 0 1 2]
[ 70 50 100]
[ 4 5 6]]
rgbL:
[[ 20, 45, 40],
[ 30, 45, 60],
..........
[ 70, 50, 100]]