我用Numpy从一个.csv文件加载了一堆16x16的图像。每一行是存储在CMO中的256个灰度值的列表(因此形状是(n256),其中n是图像的数量)。这意味着我可以用pyplot显示任何单独的图像:
plot.imshow(np.reshape(images[index], (16,16), order='F'), cmap=cm.Greys_r)
我想用每行一定数量的图像平铺这些图像。我有一个可行的解决方案:
^{pr2}$这样做非常好,但感觉应该有一个更干净的方法来做这种事情。我对Numpy有点新手,我想知道是否有一种更干净的方法来平铺扁平化的数据,而不需要所有的手动填充和条件连接。在
通常,这些简单的数组整形操作可以用Numpy在几行代码中完成,所以我觉得我遗漏了一些东西。(另外,使用“”作为标志,就好像它是一个空指针似乎有点混乱)
这是您的实现的简化版本。在
想不出更简单的方法。在
希望有帮助。在
相关问题 更多 >
编程相关推荐