1# creates the resulting image with double the size and 3 channels
2output = np.zeros((w+h+h , w + h + h, 3), dtype="uint8")
3
4# top img
5output[0:h, h:h+w] = img
6# left img (rotated 90°)
7output[h:h+w, 0:h] = np.rot90(img,1)
8# right img (rotated 270°)
9output[h:h + w, h + w:h +w +h] = np.rot90(img,3)
10# bottom img (rotated 180°)
11output[h+w:h+w+h, h:h+w] = np.rot90(img,2)
12
1import cv2
2import numpy as np
3
4#loads images and gets data
5img = cv2.imread("img.png")
6h,w,_ = img.shape
7
8# creates the resulting image with double the size and 3 channels
9output = np.zeros((h * 2, w * 2, 3), dtype="uint8")
10
11# copies the image to the top left
12output[0:h, 0:w] = img
13# copies the image to the top right
14output[0:h, w:w * 2] = img
15# copies the image to the bottom left
16output[h:h * 2, w:w * 2] = img
17# copies the image to the bottom right
18output[h:h * 2, 0:w] = img
19