首页 > 其他 > 详细

新建全色或者resize(毫无价值,只是做记录)

时间:2019-07-20 00:26:52      阅读:119      评论:0      收藏:0      [点我收藏+]
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)

 

新建全色或者resize(毫无价值,只是做记录)

原文:https://www.cnblogs.com/ziytong/p/11216126.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!