• Matplotlib使用


    实验中用到了matplotlib,简单记录一下。

    使用教程:https://matplotlib.org/users/pyplot_tutorial.html

    例子:

    from matplotlib.font_manager import FontProperties
    font_set = FontProperties(fname=r"c:windowsfontssimsun.ttc", size=12)#使用中文需要

    from PIL import Image    #Pillow图像库
    import matplotlib.pyplot as plt
    %matplotlib inline               #jupyter notebook内联显示
    from PIL import ImageFilter  #Pillow 滤波

    from PIL import ImageEnhance

    img = Image.open("./XXX.tif")

    plt.figure(figsize=(10,8),dpi=108) #
    p1 = plt.subplot(221)
    p2 = plt.subplot(222)
    p3 = plt.subplot(223)
    p4 = plt.subplot(224)

    p1.imshow(img)
    p1.set_title("原始图像",fontproperties=font_set)


    imgEH = ImageEnhance.Contrast(img)

    contrast = 1.5
    image_contrasted = imgEH.enhance(contrast)

    p2.imshow(image_contrasted)

    p2.set_title("增强对比度",fontproperties=font_set)

    enh_sha = ImageEnhance.Sharpness(img)

    sharpness = 3.0
    image_sharped = enh_sha.enhance(sharpness)


    p3.imshow(image_sharped)
    p3.set_title("锐化",fontproperties=font_set)

    enh_bri = ImageEnhance.Brightness(img)
    brightness = 1.5
    image_brightened = enh_bri.enhance(brightness)


    p4.imshow(image_brightened)
    p4.set_title("亮度增加",fontproperties=font_set)


    plt.show()

  • 相关阅读:
    ScriptManager在客户端来调用服务器端方法或者webService的方法
    转2010 .NET面试题整理之基础篇
    .net 面试题1
    读写文件
    三种编解码方式
    vs2008快捷键
    SharePoint类库说明.NET教程,Asp.Net研发
    一道sql面试题解法
    16天学完java
    总结DataTable 导出Excel数据
  • 原文地址:https://www.cnblogs.com/4c4853/p/9682820.html
Copyright © 2020-2023  润新知