from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import cv2
def findLabel( label ):
max = 0
iMax = -1
for i in range( len( label ) ) :
#print( label[i] , end = ' ' )
if label[i] > max :
max = label[i]
iMax = i
#print( "max=", max , "iMax=" , iMax )
return iMax
def main():
mnist = input_data.read_data_sets('data/',one_hot=True)
with open("bmp/28x28x8bGray.bmp" , "rb" ) as r :
head = r.read( 54 + 1024)
procList = [ [ mnist.train.num_examples , mnist.train.labels , 'trainImg/train_' , mnist.train.images ] ,
[ mnist.validation.num_examples , mnist.validation.labels , 'validationImg/valid_' , mnist.validation.images] ,
[ mnist.test.num_examples , mnist.test.labels , 'testImg/test_',mnist.test.images ] ]
tempBmp = "bmp/mnistTemp.bmp"
for ite in procList :
for i in range( ite[0] ) :
print('=',end='')
imax = findLabel ( ite[1][i] )
pngName = ite[2] + str( i ) +'_('+ str( imax) + ').png'
image= ite[3][i]*200
image1 = image.astype( np.uint8 )
with open( tempBmp , "wb" ) as f:
f.write( head )
for row in range( 27, -1 ,-1 ) :
start = row*28
f.write( image1[start:start+28 ])
iBmp = cv2.imread( tempBmp , 0 )
cv2.imwrite( pngName, iBmp )
if i % 100 == 0 :
print('\n')
main()
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
minist2Pngs.zip (10个子文件)
ministRecognize
minist_exampleToPng.py 2KB
bmp
28x28x8bGray.bmp 2KB
28x28x8.bmp 2KB
1.bmp 2KB
mnistTemp.bmp 2KB
data
t10k-images-idx3-ubyte.gz 1.57MB
t10k-labels-idx1-ubyte.gz 4KB
train-labels-idx1-ubyte.gz 28KB
train-images-idx3-ubyte.gz 9.45MB
validationImg
trainImg
testImg
minist_down.py 704B
共 10 条
- 1
资源评论
brooknew
- 粉丝: 77
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功