从4D列表构造图像 [英] Construct image from 4D list

查看:53
本文介绍了从4D列表构造图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个尺寸为(10,10,3,64)

这表示大小为10x10x3

我想创建1个大小为80x80x3的图像,其中每个图像并排放置.我不确定如何合并这些轴以确保图像完整性.

I want to create 1 image of size 80x80x3, where each image is side by side. I am not sure exactly how to merge these axes to make sure that the image integrity holds.

仅举一个例子,一个签名图像是

Just an example, a signle image is

myList[all][all][all][0]

推荐答案

IIUC解决该问题的一种方法是重塑和排列尺寸.

IIUC one way to solve it would be with reshaping and permuting dimensions.

1)重塑形状以将最后一个尺寸分为两个尺寸.

1) Reshape to split the last dimension into two dimensions.

2)换位以使最后两个分割的暗号紧接在前两个暗号的旁边.

2) Transpose to bring the last two split dims come next to the first two dims).

3)最后再次重新塑形,将前两个暗点和接下来的两个暗点合并为一个暗点.

3) Finally reshape again to merge the first two dims and next two dims into one dim each.

因此,我们将有一个类似的实现-

Thus, we would have an implementation like so -

np.array(myList).reshape(10,10,3,8,8).transpose(0,3,1,4,2).reshape(80,80,3)

这篇关于从4D列表构造图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆