获取两个图片,将其1 * 2拼接起来
获取四个图片,将其2 * 2拼接起来
import cv2
import numpy as np
img = cv2.imread("./data/2.png")
img = cv2.resize(img, None, fx=0.5, fy=0.5) #为了完整显示,缩小一倍
blur2 = cv2.blur(img, (2,2))
htich = np.hstack((img,blur2))
cv2.namedWindow('merged_img',cv2.WINDOW_NORMAL)
cv2.imshow("merged_img", htich)
cv2.waitKey(0)
cv2.destroyAllWindows()
运行结果
核心函数:np.hstack((img,blur2))
将里面的图片拼成一行
import cv2
import numpy as np
img = cv2.imread("./data/2.png")
img = cv2.resize(img, None, fx=0.5, fy=0.5) #为了完整显示,缩小一倍
blur2 = cv2.blur(img, (2,2))
blur3 = cv2.blur(img, (5,5))
blur4 = cv2.blur(img, (10,10))
htich = np.hstack((img,blur2))
htich2 = np.hstack((blur3,blur4))
vtich = np.vstack((htich, htich2))
cv2.namedWindow('merged_img',cv2.WINDOW_NORMAL)
cv2.imshow("merged_img", vtich)
cv2.waitKey(0)
cv2.destroyAllWindows()