【发布时间】:2021-06-07 06:13:42
【问题描述】:
假设我有 9 个二维数组,格式如下:
A1 = [[ a1, b1, c1 ],
[ d1, e1, f1 ],
[ g1, h1, i1 ]]
A2 = [[ a2, b2, c2 ],
[ d2, e2, f2 ],
[ g2, h2, i2 ]]
.....
A9 = [[ a9, b9, c9 ],
[ d9, e9, f9 ],
[ g9, h9, i9 ]]
我想将它们连接起来得到一个像这样的二维数组:
A = [B1, B2, B3]
在哪里
B1 = np.concatenate((A1,A2, A3),axis=1)
B2 = np.concatenate((A4,A5, A6),axis=1)
B3 = np.concatenate((A7,A8, A9),axis=1)
我将有 N 个数组,我会像这样计算 N 的值:
img = Image.open(file_name)
img_width, img_height = img.size
tile_height = int(input('Enter the height of tile:'))
tile_width = int(input("Enter the width of tile:'))
N = (img_height//tile_height)*(img_width//tile_width)
# **The image will be broken down into n tiles of size tile_width x tile_height**
for i in range(img_height//tile_height):
for j in range(img_width//tile_width):
box = (j*width, i*height, (j+1)*width, (i+1)*height)
img.crop(box)
...
所以本质上,我有一个图像被分解为 N 个图块,经过一些处理后,我将这些图像图块数据存储为 numpy 数组,我想将它们连接/合并到相同方向的单个 2D numpy 数组中作为原始图像。我该怎么做?
【问题讨论】:
标签: python arrays list numpy image-processing