zoukankan      html  css  js  c++  java
  • scipy学习之(二)——io操作及其misc操作对图片的处理

    SciPy有许多模块、类和函数,io子模块可用于从各种文件格式中读取数据和将数据写入各种文件格式。

    from scipy import io

    import numpy as np

    生成数据

    data = np.random.randint(0,100,size = (10,3))

    保存数据:保存成mat格式的二进制文件

    io.savemat("./data.mat",mdict = {"data":data})

    加载数据

    ret = io.loadmat("./data.mat")

    读取生成的数据

    ret["data"]

    显示结果:

    array([[90, 39, 31],
           [45,  8, 75],
           [75, 17,  5],
           [84, 62, 87],
           [30, 22, 32],
           [37, 15, 97],
           [67, 61, 95],
           [43, 13,  7],
           [27, 31, 40],
           [77, 25, 56]])

    misc

    是scipy中一个很杂的模块

    介绍对图片进行过滤的方式

    from scipy import misc
    import matplotlib.pyplot as plt
    %matplotlib inline

    he = misc.imread("./timg1.jpg")

    原图:

    import warnings
    warnings.filterwarnings("ignore")        #忽略警告问题

    #imfilter中的一些属性如下列表,

    类似高斯滤波的卷积操作

    array = [ 'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more','emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen']
    he1 = misc.imfilter(he,array[0])

    显示第二个属性样式
    plt.imshow(he1)

  • 相关阅读:
    C++引用之引用的使用
    C++引用之声明方法
    C++const与指针
    C++默认参数值函数
    LeanCloud 调研报告
    [译] 为何流处理中局部状态是必要的
    Z-Stack
    Think twice before starting the adventure
    Multi-pattern string match using Aho-Corasick
    C pointer again …
  • 原文地址:https://www.cnblogs.com/kuangkuangduangduang/p/10292183.html
Copyright © 2011-2022 走看看