from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
import argparse
import numpy as np
import os
from tensorflow.python import pywrap_tensorflow
from PIL import Image
mnist_data = input_data.read_data_sets("MNIST_data", one_hot = True)
def getTestPicArray(filename) :
im = Image.open(filename)
x_s = 28
y_s = 28
out = im.resize((x_s, y_s), Image.ANTIALIAS)
im_arr = np.array(out.convert('L'))
num0 = 0
num255 = 0
threshold = 100
for x in range(x_s):
for y in range(y_s):
if im_arr[x][y] > threshold : num255 = num255 + 1
else : num0 = num0 + 1
if(num255 > num0) :
print("convert!")
for x in range(x_s):
for y in range(y_s):
im_arr[x][y] = 255 - im_arr[x][y]
if(im_arr[x][y] < threshold) : im_arr[x][y] = 0
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载