新建全色或者resize(毫无价值,只是做记录)
作者:互联网
import glob import os,sys import shutil import numpy as np import cv2 import matplotlib.pyplot as plt # fileDir = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allnocalcification/' fileDir = 'F:/project/Breast/InBreast/INBreast/removeother/' source = 'F:/project/Breast/InBreast/INBreast/imgtest/20586960.png' tarDir = 'F:/project/Breast/InBreast/INBreast/labelblack/' #源图片文件夹路径 if __name__ == '__main__': txtLists = os.listdir(fileDir) # 列出文件夹下所有的目录与文件 img1 = cv2.imread(source) for filename in txtLists: print(filename) img = cv2.imread(fileDir + filename) print(type(img)) #img = np.zeros((112, 112,3)) # cv2.imread('F:/project/Breast/InBreast/INBreast/outimgpatch/allnocalcification/20586908_1.png') img2 = cv2.resize(img1,(img.shape[1],img.shape[0])) # for i in range(img.shape[0]): # for j in range(img.shape[1]): # for k in range(3): # img[i, j, k] = 0 cv2.imwrite(tarDir+filename,img2) # plt.imshow(img) # plt.show() cv2.imwrite(tarDir + '1.png', img)
标签:毫无价值,img,全色,cv2,project,Breast,InBreast,import,resize 来源: https://www.cnblogs.com/ziytong/p/11216126.html