ViewImage Date: November 28, 2023 8:54:32 Category: Code 12345import matplotlib.pyplot as pltfrom mpl_toolkits.axes_grid1 import ImageGrid%matplotlib inline #jupyter中使用,需要这一行import osimport cv2 12345#调整path = '/data/lwb/data/HPA/train/mix/pos/'N = 49row = 7col = 7 1234567img = []for i in os.listdir(path)[:N]: img_path = os.path.join(path,i) img_bgr = cv2.imread(img_path) img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB) img.append(img_rgb)len(img) 1234567891011121314fig = plt.figure(figsize=(10, 10))grid = ImageGrid(fig, 111, # 类似绘制子图 subplot(111) nrows_ncols=(row, col), # 创建 row 行 col 列的 axes 网格 axes_pad=0.05, # 网格间距 share_all=True )# 遍历每张图像for ax, im in zip(grid, img): ax.imshow(im) ax.axis('off')plt.tight_layout()plt.show() Tag(s): # Images back · home wandb Pandas