python - emnist 训练数据集中的字母被旋转并且有点模糊

标签 python machine-learning dataset

我正在使用 http://biometrics.nist.gov/cs_links/EMNIST/gzip.zip 中的 emnist-letters-train-images-idx3-ubyte.gz 和 emnist-letters-train-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)

这是输出图像 montage of letters a to z
我的问题是 -i​​ 和 l 不可区分,r 无法识别,很多字母倒置。这是为什么?

谢谢。

最佳答案

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

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

相关文章:

python - GtkTextView : How to change background color of current active blinking cursor line?

python - Dask 的 imread 返回 MemoryError - 在导入时更改 block 大小

machine-learning - 如何查看每个单词的 tf-idf 分数

machine-learning - 如何标准化 SVM 的 tf-idf 向量?

python - 一维数据中的阈值

javascript - BIRT 动态图像 url - 无法访问数据列

c# - DbDataReader、NextResult() 和填充多个表

python - 如何在 PythonAnywhere 上部署 web2py?

python - 如何让PyQt App放弃窗口焦点?

C# - 获取字段类型