• 提出钙化簇


    import glob
    import os,sys
    import shutil
    import numpy as np
    import cv2
    import matplotlib.pyplot as plt
    
    
    
    import os, random, shutil,cv2
    
    # labelDir = 'F:/project/Breast/InBreast/INBreast/Unet/data/Inbreast/yes/test/label/'
    # imageDir = 'F:/project/Breast/InBreast/INBreast/Unet/data/Inbreast/yes/test/image/'
    # labelDir1 = 'F:/project/Breast/InBreast/INBreast/Unet/data/Inbreast/no/test/label/'
    # imageDir1 = 'F:/project/Breast/InBreast/INBreast/Unet/data/Inbreast/no/test/image/'
    import time
    import os
    import math
    import sys
    import os,os.path,shutil
    import numpy as np
    import re
    
    txtPath = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allouttxtpatch/'
    imagePath = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allcalcification/'
    labelPath = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allcalcificationimglabel/'
    noimagePath = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allnocalcification/'
    nolabelPath = 'F:/project/Breast/InBreast/INBreast/outimgpatch/allnocalcificationlabel/'
    
    imagePath1 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/images/'
    labelPath1 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/labels/'
    noimagePath1 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/noimages/'
    nolabelPath1 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/nolabels/'
    
    imagePath2 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/others/images/'
    labelPath2 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/others/labels/'
    noimagePath2 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/others/noimages/'
    nolabelPath2 = 'F:/project/Breast/InBreast/INBreast/outimgpatch/newcalcification/others/nolabels/'
    
    txtType = 'txt'
    txtLists = os.listdir(txtPath) #列出文件夹下所有的目录与文件
    print(txtLists)
    
    # Read the points(before 11:30,712)
    # Convert points to digital form(before 2:30,712)
    # Obtain the right batch(before 5.00, 712)
    for filename in txtLists:
        print(filename)
        name = filename[:-4] + '.png'
        print(name)
        with open(txtPath + filename, 'r') as file:
            lines = file.readlines()
            dataset = [[] for i in range(len(lines))]
            for i in range(len(dataset)):
                dataset[i][:] = (item for item in lines[i].strip().split(','))  # 逐行读取数据
            print(i)
    
            if os.path.exists(imagePath + name):
                if i > 3:
                    print("yes")
                    shutil.copy(imagePath + name, imagePath2 + name)
                    shutil.copy(labelPath + name, labelPath2 + name)
                    shutil.copy(noimagePath + name, noimagePath2 + name)
                    shutil.copy(nolabelPath + name, nolabelPath2 + name)
                if i <= 3:
                    print("no")
                    shutil.copy(imagePath + name, imagePath1 + name)
                    shutil.copy(labelPath + name, labelPath1 + name)
                    shutil.copy(noimagePath + name, noimagePath1 + name)
                    shutil.copy(nolabelPath + name, nolabelPath1 + name)
    
    
    
    
            # print("dateset:", dataset)
            # # print(type(dataset[0][0]))
            # # print(dataset.__sizeof__())
            # u = np.array(dataset)
            # for i in range(u.shape[0]):
            #     # print(u[i,0][0])
            #     findNumber = u[i,0].find(" ")
            #     # print(findNumber)
            #     x = round(float(u[i, 0][0:findNumber]))
            #     findNumber1 = u[i, 0][findNumber+1:].find(" ")
            #     y = round(float(u[i, 0][findNumber+1: findNumber + findNumber1]))
            #     print(x,y)
    
    
    
    
    
    
    
    
    
            # name = '0_'+str(i)+'_predict.png'
            # i =i + 2
            # print(name)
            # shutil.copy(fileDir + filename, tarDir + name)
            # if filename.startswith('yes'):
            #     filename1 = filename[4:]
            #     print(filename1)
            #     filename2 = os.path.join(tarDir, filename1.split('.')[0] + '_yes.png')
            #     print(filename2)
            # elif filename.startswith('no'):
            #     filename1 = filename[3:]
            #     print(filename1)
            #     filename2 = os.path.join(tarDir, filename1.split('.')[0] + '_no.png')#filename1 + '_no'
            #     print(filename2)
            #
            # img = cv2.imread(fileDir + filename)
            # image = img[:,:,0]
            # cv2.imwrite(filename2,image)
            # name = 'yes_' + filename#'yes_0_'+ str(i) + '_predict.png'
            # name1 = 'no_' + filename#'yes_0_'+ str(i) + '_predict.png'
            # i = i + 1
            # print(filename,name)
            # shutil.copy(fileDir + filename, tarDir + name)
            # shutil.copy(fileDir2 + filename, tarDir + name1)
            # shutil.copy(fileDir1 + filename, tarDir1 + name)
            # shutil.copy(fileDir22 + filename, tarDir1 + name1)
            # image1 = cv2.imread(fileDir + filename)
            # label1 = cv2.imread(fileDir1 + filename)
            # image2 = cv2.resize(image1,(448,448))
            # label2 = cv2.resize(label1,(448,448))
            # cv2.imwrite(fileDir + filename, image2)
            # cv2.imwrite(fileDir1 + filename,label2)
    #         # source = fileDir + filename
    #         # print(source)
    
            # shutil.copy(fileDir2 + filename, tarDir2 + name)
            # shutil.copy(fileDir3 + filename, tarDir3 + name)
  • 相关阅读:
    查找 Linux 父进程的方法
    Flask 使用日志
    Jenkins Pipeline 编译后端 Java 代码
    K8S 指定 nfs 挂载
    K8S ingress nginx 设置访问白名单
    Jenkins Pipeline 编译前端 NodeJS 代码
    在 K8S 中测试环境中搭建 mongodb
    K8S argocd 安装配置
    搭建私有 helm 仓库 chartmuseum
    Helm templates 中的语法
  • 原文地址:https://www.cnblogs.com/ziytong/p/11380773.html
Copyright © 2020-2023  润新知