Python文件夹下图像数据可视化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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文件夹下图像数据可视化的主要内容,如果未能解决你的问题,请参考以下文章
太强大了!一款可以像操作Excel一样玩Pandas的可视化神器来了!