黑松山资源网 Design By www.paidiu.com
原始图像绝对路径的图像名存储在一个txt文件中,下面的程序实现的功能是按照txt文件的顺序,依次将图片读取然后进行处理,最后将处理之后的图像保存在指定的路径下:
# Read in the image to be detected # 原始图像均保存在binaries.txt文件中,将包含绝对目录的图像名提取出来并写到txt文件的程序见上一篇博客 f = open("/home/shenruixue/image_test/binaries.txt") line = f.readline() while line: count_times += 1 line = line[:-1] # 除去末尾的换行符 print line print '***********************************************************' image = caffe.io.load_image(line) # start time start = time.clock() # 此处做一系列的处理 # 。。。。。。 # 。。。。。。 # 此处做一系列的处理 # end time end = time.clock() sum_time += (end - start) # draw the image plt.imshow(image) print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' # 指定处理之后的图像的保存目录 pre_savename = '/home/shenruixue/image_test_result/' print (str(count_times)) # 将从txt中读取的一行字符串(包含绝对路径的图像名)进行处理,只留存最后的图像名的字符串部分,去掉绝对路径部分的字符串 # 并将自己指定的目录与原始的图像名这两个字符串连接起来,然后进行保存 savename = os.path.join(pre_savename, line[28:]) print 'line is ' print line print 'savename is ' print savename savefig(savename) #io.imsave(savename, image) # 继续读取下一行的图像名称 line = f.readline() print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' plt.pause(1) plt.close() print('Running time: %s s' %sum_time) print('Deal with images: %s 张' %count_times) print('mean time: %s s' %(sum_time / count_times))
以上这篇python将处理好的图像保存到指定目录下的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月07日
2024年10月07日
- 张柏芝《全新经验》[FLAC/分轨][450MB]
- 唐朝.2008-浪漫骑士【音乐家】【WAV+CUE】
- 张芸京.2016-失败的高歌【泡耳音乐】【WAV+CUE】
- 群星.1991-音乐工厂1·皇后大道东【音乐工厂】【WAV+CUE】
- 群星.1992-音乐工厂2·首都【音乐工厂】【WAV+CUE】
- 群星.1994-音乐工厂3·儿童乐园【音乐工厂】【WAV+CUE】
- 胡鸿钧.2021-ex:CHANGE【星梦娱乐】【WAV+CUE】
- 班得瑞原装进口《第一张新世纪专辑:仙境》1CD[APE/CUE分轨][292.3MB]
- 伍佰《摇滚教父 伍佰黄金精选 2CD》[WAV+CUE][990MB]
- 班得瑞原装进口《第二张新世纪专辑:寂静山林》1CD[APE/CUE分轨][327.1MB]
- Beyond.1989-真的见证(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 陈怡婷.2024-予你的心谁来赔【福茂】【FLAC分轨】
- 陈冠希.2003-HITS.OR.MISSES【英皇娱乐】【WAV+CUE】
- 班得瑞原装进口《第三张新世纪专辑:春野》1CD[APE/CUE分轨][278.9MB]
- 班得瑞原装进口《第四张新世纪专辑:蓝色天际》1CD[APE/CUE分轨][284.8MB]