→
import os
import cv2
import matplotlib.pyplot as plt
PATH = "./1" #文件路径
i = 0
#子文件夹路径
img1=0
for parent, dirs, files in os.walk(PATH):
for file in files:
if not file.endswith('.png'):
continue
img= cv2.imread(os.path.join(parent, file))
if i==0:
img1=img
imgadd1=img
i = i + 1
continue
# img = cv2.resize(img, (img1.shape[1], img1.shape[0]))
imgadd1 = img1+img # cv2.add(img, img1)
img1=imgadd1
i = i + 1
print(i)
plt.imshow(imgadd1)