matplotlib教程学习笔记

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np

载入图像为ndarray

img = mpimg.imread("ccc.png")
print(img.shape)  #(4160,2336, 4)#RGBA?
print(img)  #ndarray

显示图像

imgplot = plt.imshow(img)

调取各个维度

fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize=(10, 30),sharey=True)
ax1.imshow(img[:, :, 0])
ax2.imshow(img[:, :, 1])
ax3.imshow(img[:, :, 2])
ax4.imshow(img[:, :, 3])

利用cmp

lum_img = img[:, :, 2]
plt.imshow(lum_img, cmap="hot")

imgplot = plt.imshow(lum_img)
imgplot.set_cmap('nipy_spectral')
imgplot = plt.imshow(lum_img)
plt.colorbar() #添加标度

获得像素点的RGB的统计

plt.hist(lum_img.ravel(), bins=256, range=(0.0, 1.0), fc='k', ec='k')

通过clim来限定rgb

imgplot = plt.imshow(lum_img, clim=(0.3, 0.7))

标度在下方

fig = plt.figure()
a = fig.add_subplot(1, 2, 1)#mnk
imgplot = plt.imshow(lum_img)
a.set_title('Before')
plt.colorbar(ticks=[0.1, 0.3, 0.5, 0.7], orientation='horizontal') #水平放置的colorbar 位置
a = fig.add_subplot(1, 2, 2)
imgplot = plt.imshow(lum_img)
imgplot.set_clim(0.0, 0.7)
a.set_title('After')
plt.colorbar(ticks=[0.1, 0.3, 0.5, 0.7], orientation='horizontal')

插值,马赛克,虚化

from PIL import Image

img = Image.open('C:/Users/pkavs/Desktop/ccc.png')
img.thumbnail((64, 64), Image.ANTIALIAS)  # resizes image in-place
imgplot = plt.imshow(img)
imgplot = plt.imshow(img, interpolation="nearest")
imgplot = plt.imshow(img, interpolation="bicubic")





matplotlib 入门之Image tutorial的更多相关文章

  1. matplotlib 入门之Pyplot tutorial

    文章目录 pyplot 介绍 修饰你的图案 格式字符串 [color][marker][line] Colors Markers Line Styles 利用关键字作图(大概是数据映射到属性吧) 传入 ...

  2. Sahi (1) —— 快速入门(101 Tutorial)

    Sahi (1) -- 快速入门(101 Tutorial) jvm版本: 1.8.0_65 sahi版本: Sahi Pro 6.1.0 参考来源: Sahi官网 Sahi Quick Tutori ...

  3. 绘图神器-matplotlib入门

    这次,让我们使用一个非常有名且十分有趣的玩意儿来完成今天的任务,它就是jupyter. 一.安装jupyter matplotlib入门之前,先安装好jupyter.这里只提供最为方便快捷的安装方式: ...

  4. Python 绘图库Matplotlib入门教程

    0 简单介绍 Matplotlib是一个Python语言的2D绘图库,它支持各种平台,并且功能强大,能够轻易绘制出各种专业的图像. 1 安装 pip install matplotlib 2 入门代码 ...

  5. Matplotlib 入门

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

  6. matplotlib 入门之Sample plots in Matplotlib

    文章目录 Line Plot One figure, a set of subplots Image 展示图片 展示二元正态分布 A sample image Interpolating images ...

  7. IPython绘图和可视化---matplotlib 入门

    最近总是需要用matplotlib绘制一些图,由于是新手,所以总是需要去翻书来找怎么用,即使刚用过的,也总是忘.所以,想写一个入门的教程,一方面帮助我自己熟悉这些函数,另一方面有比我还小白的新手可以借 ...

  8. python数据处理matplotlib入门(2)-利用随机函数生成变化图形

    综合前述的类.函数.matplotlib等,完成一个随机移动的过程(注意要确定移动的次数,比如10万次),每次行走都完全是随机的,没有明确的方向,结果是由一系列随机决策确定的,最后显示出每次移动的位置 ...

  9. python 绘图工具 matplotlib 入门

    转自: http://www.cnblogs.com/kaituorensheng/p/3440273.html matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的 ...

随机推荐

  1. javascript 重要属性之prototype(继承)

    转载猫猫小屋 http://www.maomao365.com/?p=831 在javascript中每一个函数都拥有 prototype属性,在javascript中使用prototype,可以向已 ...

  2. 关于C#List中FindAll用法的一些简单示例

    using System; using System.Collections.Generic; public partial class List : System.Web.UI.Page { pro ...

  3. OpenSSL 正确安装

    经过几天的各种尝试,总算正常安装了openssl,中途差点各种放弃,最后总算装好了. 环境:Win10 , 为了装OpenSSL 而安装了vs2010,没有验证必须要装的 安装步骤: .从openss ...

  4. 消除Warning: Using a password on the command line interface can be insecure的提示

    最近在部署Zabbix时需要用脚本取得一些MySQL的返回参数,需要是numberic格式的,但是调用脚本时总是输出这一句: Warning: Using a password on the comm ...

  5. Linux Rsyslog日志集中管理

    Linux Rsyslog日志集中管理 一.Rsyslog简介 ryslog 是一个快速处理收集系统日志的程序,提供了高性能.安全功能和模块化设计.rsyslog 是syslog 的升级版,它将多种来 ...

  6. scrapy中pipeline的一点综合知识

    初次学习scrapy ,觉得spider代码才是最重要的,越往后学,发现pipeline中的代码也很有趣, 今天顺便把pipeline中三种储存方法写下来,算是对自己学习的一点鼓励吧,也可以为后来者的 ...

  7. Excel 单元格不能设置超链接

    最近在重做系统后  新安装office后 原先的Excel中设置的超链接不能正常使用了  如果新配置的超链接也不能使用 解决方法: 步骤1:打开开始菜单,在运行里输入regedit,回车 步骤2  在 ...

  8. nginx配置文件服务器

    server{ listen  端口号; server_name   localhost; charset utf-8; root    放文件的路径; location   /xxx/yyy/ { ...

  9. Linux 系统故障排查和修复技巧

    Linux 系统故障排查和修复技巧 我发现Linux系统在启动过程中会出现一些故障,导致系统无法正常启动,我在这里写了几个应用单用户模式.GRUB命令操作.Linux救援模式的故障修复案例帮助大家了解 ...

  10. 字符编码ASCII,Unicode 和 UTF-8

    一直对编码的概念很模糊,今天抽空突然想了解下,就找到了这个文章,看完真的豁然开朗,必须感谢阮一峰先生. 一.ASCII 码 我们知道,计算机内部,所有信息最终都是一个二进制值.每一个二进制位(bit) ...