我正在使用http://biometrics.nist.gov/cs_links/EMNIST/gzip.zip中的emnist-letters-train-images-idx3-ubyte.gz和emnist-letters-trains-labels-idx1-ubyte.gz
我写了这个小脚本看图片

import os
import struct
import numpy as np
import scipy.misc
np.set_printoptions(threshold='nan')
path = './'
fname_img = os.path.join(path, 'emnist-letters-train-images-idx3-ubyte')
fname_lbl = os.path.join(path, 'emnist-letters-train-labels-idx1-ubyte')
with open(fname_lbl, 'rb') as flbl:
        magic, num = struct.unpack(">II", flbl.read(8))
        lbl = np.fromfile(flbl, dtype=np.int8)
with open(fname_img, 'rb') as fimg:
    magic, num, rows, cols = struct.unpack(">IIII", fimg.read(16))
    img = np.fromfile(fimg, dtype=np.uint8).reshape(len(lbl), rows, cols)
print 'image',img.shape
print 'label',lbl.shape
labels, indices = np.unique(lbl,return_index=True)
print 'unique labels',labels
print 'unique indices',indices
    for i in indices:
        image = img[i]
        for y in image:
            row = ""
            for x in y:
                row += '{0: <4}'.format(x)
            print row
        print 'label',lbl[i],'\n'
        newfilename = str(lbl[i]) + '.jpg'
        scipy.misc.imsave(newfilename, image)


这是输出图像python - Emnist训练数据集中的字母旋转且模糊不清-LMLPHP
我的问题是-i和l是不可区分的,r是无法识别的,许多字母都是倒数的。这是为什么 ?

谢谢。

最佳答案

水平翻转图像,然后将其逆时针旋转90度。

关于python - Emnist训练数据集中的字母旋转且模糊不清,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48532761/

10-12 22:20