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()

  • 相关阅读:
    Storm监控文件夹变化 统计文件单词数量
    Storm默认配置 default.yaml
    Storm集群搭建
    Storm概念
    zookeeper安装
    zookeeper
    zookeeper应用
    zookeeper应用
    zookeeper应用
    HDU 3473 Minimum Sum (划分树求区间第k大带求和)(转)
  • 原文地址:https://www.cnblogs.com/4c4853/p/9682820.html
Copyright © 2011-2022 走看看