我试图显示5个图像从每个子文件夹,这是图像类。我的代码只显示了5张头等舱(ak)的图片。我还将图像的标题显示给它对应的类。请参考下面的代码。
label = ['AK', 'BCC','BKL','DF','MEL','NV','SCC','VASC']
label_images = []
classes = [ 'Actinic Keratoses', 'Basal cell carcinoma', 'Benign Keratosis-like lesions',
'Dermatofibroma','Melanoma', 'Melanocytic nevi', 'Squamous cell carcinoma' , 'Vascular lesions']
fig = plt.figure(figsize=(20, 20))
for l in label:
dir_path = os.path.join(path,l)
for i,file in enumerate(os.listdir(dir_path)[0:5]):
fullpath = dir_path+ "/" + file
img=cv2.imread(fullpath)
plt.subplot(8, 5, i+1)
plt.imshow(img)
plt.axis('off')
if i%5 == 0:
title = int(i/5)
plt.title(classes[title], loc='left', size=20)
plt.tight_layout()
plt.show()
暂无答案!
目前还没有任何答案,快来回答吧!