如何将图像附加到 numpy 数组中?
我试图用这个形状(number_of_images,32,32)制作一个numpy,所有图像都具有相同的尺寸:32,32 这是我的代码:
data=np.array([])
for filename in glob.glob(path+'*.tif'):
im = np.array([np.array(cv2.imread(filename, cv2.IMREAD_GRAYSCALE))])
#im = preprocess(im)
im = NormalizeData(im)
data=np.append(data,im)
我的形状是(1,32,32)。然而数据形状不是我想要的(number_of_images,32,32)。我目前拥有的是(113664,)
I'm trying to make a numpy with this shape(number_of_images,32,32) all the images have the same dimensions: 32,32
here is my code:
data=np.array([])
for filename in glob.glob(path+'*.tif'):
im = np.array([np.array(cv2.imread(filename, cv2.IMREAD_GRAYSCALE))])
#im = preprocess(im)
im = NormalizeData(im)
data=np.append(data,im)
im shape is (1,32,32). however data shape is not the one I wanted (number_of_images,32,32). the one I currently have is (113664,)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用列表并在最后转换为 numpy - 减少混乱
输出:
try using lists and at the end cast to numpy - less confusing
Output: