zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    时间记录日志
    软件工程作业02
    个人学习进度(第二周)
    《大道至简》第二章读后感
    《大道至简》第一章读后感
    构建之法阅读笔记02
    构建之法阅读笔记01
    web开发
    Tomcat的安装与环境配置
    java-10异常处理动手动脑
  • 原文地址:https://www.cnblogs.com/4c4853/p/9682820.html
Copyright © 2011-2022 走看看