此处为yale人脸数据的读取,可视化
import numpy as np
import matplotlib.pyplot as plt
from scipy import io
import cv2 as cv
#像numpy,matplotlib,scipy,cv2这些包。直接下一个Anaconda就可以
#Anaconda里面各种包都有,如果你是新手多百度看看什么是包,这些包有什么作用
#遇到不会多百度
x=io.loadmat('C://Users//dell//Desktop//Maching_Learning//YALE人脸数据集可视化//.idea//Yale_32x32.mat')
#载入YALE32mat文件的方法,得到的x是一个字典,可以print一下他的shape看一下里面的属性
data=[]
print(x['fea'].shape)
#数据都存在了fea这个键值里面,print出来发现是165*1024说明有165张
#图片每张图片都有1024个特征也就是1024个像素点
num=x['fea'].shape[0]
#得到总共样本的个数165张图片
#print(x['fea'].shape[0])
for i in range(num):
img=np.array(1024)#先创建一个一行1024列的数组
img=x['fea'][i]#存放每张图片数据
img.shape=32,32#把这1x1024的数组reshape成32x32的矩阵
img=img.T#矩阵转置
data.append(img)#把处理过大小的图片存到data列表里面
data=np.array(data)#把列表转成数组矩阵型
out=[0]*15 #我们想要搞出个15行11列的一整张图先处理行上
for i in range(1