赞
踩
我有一张大图一张小图想同时显示在一个窗口,并且希望一张窗口中的每张图片显示的时候都没有被拉伸。
同一个窗口显示:
from cv2 import cv2 import numpy as np # 作者:球场书生 # 日期:2021/12/15 image = cv2.imread("1.jpg") transformed_image =cv2.imread("2.jpg") h0,w0=image.shape[0],image.shape[1] #cv2 读取出来的是h,w,c h1,w1=transformed_image.shape[0],transformed_image.shape[1] h=max(h0,h1) w=max(w0,w1) org_image=np.ones((h,w,3),dtype=np.uint8)*255 trans_image=np.ones((h,w,3),dtype=np.uint8)*255 org_image[:h0,:w0,:]=image[:,:,:] trans_image[:h1,:w1,:]=transformed_image[:,:,:] all_image = np.hstack((org_image[:,:w0,:], trans_image[:,:w1,:])) cv2.imshow("compare image", all_image) cv2.waitKey(0)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。