首页 > 代码库 > Python文件夹下图像数据可视化
Python文件夹下图像数据可视化
Python文件夹下图像数据可视化
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
- import numpy as np
- import urllib2
- import urllib
- import os
- import shutil
- subdir= "/7"
- homedir = os.getcwd() + subdir
- # "/home/haoyou/Dev/last_caffe_with_stn/myprojects/spn-mnistcluttered/mnist-cluttered/"+subdir
- import os
- def walk_dir(dir,fileinfo,topdown=True):
- for root, dirs, files in os.walk(dir, topdown):
- for name in files:
- print(os.path.join(name))
- fileinfo.write(os.path.join(root,name) + ‘\n‘)
- for name in dirs:
- print(os.path.join(name))
- fileinfo.write(‘ ‘ + os.path.join(root,name) + ‘\n‘)
- fileinfo = open(homedir+‘/list.txt‘,‘w‘)
- walk_dir(homedir,fileinfo)
- f = open(homedir+"/list.txt", "r")
- while True:
- for i in range(1,101):
- line = f.readline()
- if line:
- line=line.strip()
- plt.subplot(10,10,i)
- lena = mpimg.imread(line)
- plt.imshow(lena,cmap=‘gray‘)
- plt.axis(‘off‘)
- else:
- break
- plt.show()
- # for line in f:
- # #pass # do something here
- # line=line.strip()
- # print(line)
- # lena = mpimg.imread(line)
- f.close()
Python文件夹下图像数据可视化
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。