• 大小: 9KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: Python
  • 标签: 数字识别  

资源简介

在规则化的图片中,进行归一化整,用支持向量机进行模式学习,进而出结果

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
“““
Created on Sun Nov 19 16:44:19 2017

@author: Administrator
“““
import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt
import matplotlib.image as im 
import scipy as sp
import random 
import re 
from sklearn import svm 


‘‘‘
a8 = im.imread(‘fsdf.jpg‘)           ###读取图片
sp.misc.imsave(‘fsdf.jpg‘  arr8)    ###矩阵保存图片
plt.rcParams[‘font.sans-serif‘] = [‘SimHei‘]  # 用来正常显示中文标签
plt.rcParams[‘axes.unicode_minus‘] = False  # 用来正常显示负号
plt.style.use(‘ggplot‘) #可以绘制出ggplot的风格
‘‘‘

plt.figure(figsize = (1010))
def get_matrix() :
    arr0 = np.array([
        [0011111100]#0
        [0011111100]
        [0011001100]
        [0011001100]
        [0011001100]
        [0011001100]#5
        [0011001100]
        [0011001100]
        [0011111100]
        [0011111100]#9
        ])

    arr1 = np.array([
        [0000110000]#0
        [0000110000]
        [0000110000]
        [0000110000]
        [0000110000]
        [0000110000]#5
        [0000110000]
        [0000110000]
        [0000110000]
        [0000110000]#9
        ])

    arr2 = np.array([
        [0011111100]#0
        [0011111100]
        [0000001100]
        [0000001100]
        [0011111100]
        [0011111100]#5
        [0011000000]
        [0011000000]
        [0011111100]
        [0011111100]#9
        ])


    arr3 = np.array([
        [0011111100]#0
        [0011111100]
        [0000001100]
        [0000001100]
        [0000111100]
        [0000111100]#5
        [0000001100]
        [0000001100]
        [0011111100]
        [0011111100]#9
        ])


    arr4 = np.array([
        [0011001100]#0
        [0011001100]
        [0011001100]
        [0011001100]
        [0011111100]
        [0011111100]#5
        [0000001100]
        [0000001100]
        [0000001100]
        [0000001100]#9
        ])


    arr5 = np.array([
        [0011111100]#0
        [0011111100]
        [0011000000]
        [0011000000]
        [0011111100]
        [0011111100]#5
        [0000001100]
        [0000001100]
        [0011111100]
        [0011111100]#9
        ])


    arr6 = np.array([
        [0011111100]#0
        [0011111100]
        [0011000000]
        [0011000000]
        [0011111100]
        [0011111100]#5
   

评论

共有 条评论