MNIST手写数字数据库保存为*.bmp图像之MATLAB源程序
来源:互联网 发布:怎样提高淘宝信誉度 编辑:程序博客网 时间:2024/06/08 00:56
MNIST手写数字数据库保存为*.bmp图像之MATLAB源程序
手写数字库很容易建立,但是总会很浪费时间。Google实验室的Corinna Cortes和纽约大学柯朗研究所的Yann LeCun建有一个手写数字数据库,训练库有60,000张手写数字图像,测试库有10,000张。源图像数据可访问原站 http://yann.lecun.com/exdb/mnist/进行下载,或到 http://download.csdn.net/detail/destiny0321/9167873进行下载,该数据库的一个文件中包含了所有的图像,使用起来很不方便。笔者在MATLAB平台上将该数据包保存为一张一张的带有标识的.bmp图片文件,以供今后研究使用。
- 首先讲解一下train-images.idx3-ubyte这个数据库个存储格式:
训练集图像格式(train-images.idx3-ubyte)
offset——–type————–value———- description
0000 —32 bit integer——0x00000803—–magic number
0004—32 bit integer——–60000——number of images
0008—32 bit integer———-28———–number of rows
0012—32 bit integer———-28——–number of columns
0016—unsigned byte ——–??——————pixel
0017—unsigned byte ——–??——————pixel
……..
xxxx—unsigned byte———??——————pixel
可见,前32bit*4对数据库进行了整体描述,之后是大小为8bit的像素值,也就是我们所需要的数据。
- 其次讲解一下train-labels.idx1-ubyte这个数据库个存储格式:
训练集标签格式(train-labels.idx1-ubyte)
offset——–type—————-value———- description
0000 —32 bit integer——0x00000803—–magic number
0004—32 bit integer——–60000——number of images
0008—unsigned byte ———??——————number
0009—unsigned byte ———??——————number
……..
xxxx—unsigned byte———-??——————number
可见,前32bit*2对数据库进行了整体描述,之后是大小为8bit的范围从0到9的数字标签,依次对应于train-images.idx3-ubyte中每幅图像所表示的数字。
对这两个文件有了清楚的认识之后,就很容易对其进行操作,获取我们想得到的*.bmp图像数据了。这是程序运行后的截图:
- 源程序如下:
fid_image=fopen('train-images.idx3-ubyte','r');fid_label=fopen('train-labels.idx1-ubyte','r');% Read the first 16 Bytesmagicnumber=fread(fid_image,4);size=fread(fid_image,4);row=fread(fid_image,4);col=fread(fid_image,4);% Read the first 8 Bytesextra=fread(fid_label,8);% Read labels related to imagesimageIndex=fread(fid_label);Num=length(imageIndex);% Count repeat times of 0 to 9cnt=zeros(1,10);for k=1:Num image=fread(fid_image,[max(row),max(col)]); % Get image data val=imageIndex(k); % Get value of image for i=0:9 if val==i cnt(val+1)=cnt(val+1)+1; end end if cnt(val+1)<10 str=[num2str(val),'_000',num2str(cnt(val+1)),'.bmp']; elseif cnt(val+1)<100 str=[num2str(val),'_00',num2str(cnt(val+1)),'.bmp']; elseif cnt(val+1)<1000 str=[num2str(val),'_0',num2str(cnt(val+1)),'.bmp']; else str=[num2str(val),'_',num2str(cnt(val+1)),'.bmp']; end imwrite(image',str);endfclose(fid_image);fclose(fid_label);
- MNIST手写数字数据库保存为*.bmp图像之MATLAB源程序
- MATLAB自动识别MNIST手写数字数据库
- MATLAB自动识别MNIST手写数字数据库
- MNIST手写数字数据库
- MNIST手写数字数据库
- 使用转换mnist数据库保存为bmp图片
- 使用转换mnist数据库保存为bmp图片
- 使用转换mnist数据库保存为bmp图片
- Keras 浅尝之MNIST手写数字识别
- 显示mnist手写数字
- MNIST手写数字识别
- 基于Tensorflow的用MNIST手写数字做图像检索
- VC保存和显示数据库图像(BMP)
- VC保存和显示数据库图像(BMP)
- Tensorflow之 CNN卷积神经网络的MNIST手写数字识别
- TensorFlow MNIST 手写数字识别之过拟合
- TensorFlow 卷积神经网络之MNIST 手写数字识别
- 【CNTK】CNTK学习笔记之制作自己的数据集(以MNIST手写数字数据集为例)
- android studio java.lang.UnsatisfiedLinkError
- HDU 1717 数学
- linux mongodb配置
- Shell学习(一)
- Android中索引关联联系人
- MNIST手写数字数据库保存为*.bmp图像之MATLAB源程序
- nyoj586 疯牛
- c#中多线程修饰符volatile
- 搭建pip本地源
- 【C++11】新特性——引入nullprt
- 机器学习(五)逻辑回归分类
- ios andorid ui图之间的转换
- java中continue、break、return
- 强连通性(poj1236 poj2186)