绘制直方图

from skimage import exposure

# 绘制彩色图像的c通道的直方图

img_hist, bins = exposure.histogram(img[..., c], source_range=‘dtype‘)

# 以第c行第i列的形式绘制归一化直方图

axes[c, i].plot(bins, img_hist / img_hist.max())

绘制累积直方图

from skimage import exposure

img_cdf, bins = exposure.cumulative_distribution(img[..., c])

axes[c, i].plot(bins, img_cdf)

直方图匹配(histogram matching)

含义:使源图像的累积直方图和目标图像一致

from skimage.exposure import match_histograms

# 参数1:源图像;参数2:目标图像;参数3:多通道匹配

matched = match_histograms(image, reference, multichannel=True)

实验:直方图匹配效果

"""

==================

Histogram matching

==================

This example demonstrates the feature of histogram matching. It manipulates the

pixels of an input image so that its histogram matches the histogram of the

reference image. If the images have multiple channels, the matching is done

independently for each channel, as long as the number of channels is equal in

the input image and the reference.2

Histogram matching can be used as a lightweight normalisation for image

processing, such as feature matching, especially in circumstances where the

images have been taken from different sources or in different conditions (i.e.

lighting).

"""

import matplotlib.pyplot as plt

from skimage import data

from skimage import exposure

from skimage.exposure import match_histograms

reference = data.coffee()

image = data.chelsea()

matched = match_histograms(image, reference, multichannel=True)

fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3),

sharex=True, sharey=True)

for aa in (ax1, ax2, ax3):

aa.set_axis_off()

ax1.imshow(image)

ax1.set_title(‘Source‘)

ax2.imshow(reference)

ax2.set_title(‘Reference‘)

ax3.imshow(matched)

ax3.set_title(‘Matched‘)

plt.tight_layout()

plt.show()

######################################################################

# To illustrate the effect of the histogram matching, we plot for each

# RGB channel, the histogram and the cumulative histogram. Clearly,

# the matched image has the same cumulative histogram as the reference

# image for each channel.

fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(8, 8))

for i, img in enumerate((image, reference, matched)):

for c, c_color in enumerate((‘red‘, ‘green‘, ‘blue‘)):

img_hist, bins = exposure.histogram(img[..., c], source_range=‘dtype‘)

axes[c, i].plot(bins, img_hist / img_hist.max())

img_cdf, bins = exposure.cumulative_distribution(img[..., c])

axes[c, i].plot(bins, img_cdf)

axes[c, 0].set_ylabel(c_color)

axes[0, 0].set_title(‘Source‘)

axes[0, 1].set_title(‘Reference‘)

axes[0, 2].set_title(‘Matched‘)

plt.tight_layout()

plt.show()

实验输出

原文:https://www.cnblogs.com/wojianxin/p/12641405.html

python 直方图匹配_python库skimage 绘制直方图;绘制累计直方图;实现直方图匹配(histogram matching)...相关推荐

  1. python turtle工具箱_python 库之 turtle(图形绘制) 开启新的快乐源泉

    python 库之 turtle(图形绘制) 开启新的快乐源泉 相信有不少人学习 python 都是听了老前辈的推荐 "学 python 好, python 有趣的代码多" 比如说 ...

  2. python canny函数_python库skimage 应用canny边缘探测算法

    Canny算法 skimage库中函数 skimage.feature.canny(image, sigma=1.0, low_threshold=None, high_threshold=None, ...

  3. python图片矫正后对比_python库skimage 对图像进行gamma校正和log校正

    Gamma校正 Gamma校正是对输入图像灰度值进行的非线性操作,使输出图像灰度值与输入图像灰度值呈指数关系: 这个指数即为Gamma. Gamma校正的原理很简单,就一个很简单的表达式,如下图所示: ...

  4. python 灰度图像_python库skimage 给灰度图像染色

    灰度图像染成红色和黄色 # 1.将灰度图像转换为RGB图像 image = color.gray2rgb(grayscale_image) # 2.保留红色分量和黄色分量 red_multiplier ...

  5. python animation 轨迹_Python实例:自动轨迹绘制

    1. 问题分析 需求:根据脚本来绘制图形 Python的 turtle 库通过写代码的方式来绘图,现在我们要根据数据来绘制轨迹. 使用数据脚本时自动化最重要的第一步.例如,根据下面的几组数据绘制出的图 ...

  6. python图形设置_python学习笔记——基本图形绘制

    1.python蟒蛇python蟒蛇代码 #PythonDraw.py import turtle turtle.setup(650,350,200,200)# 设置画布的长.宽.起点 turtle. ...

  7. python画气泡图_python使用Plotly绘图工具绘制气泡图

    今天来讲讲如何使用Python 绘图工具,Plotly来绘制气泡图. 气泡图的实现方法类似散点图的实现.修改散点图中点的大小,就变成气泡图. 实现代码如下: import plotly as py i ...

  8. python dict下标_Python库collections详解

    collections模块包含了除了内置类型list.dict.tuple之外的容器类型.本文详细介绍了Counter.defaultdict.namedtuple.OrderedDict.Chain ...

  9. python阶梯图_Python制图你真的会吗?一文学会如何绘制漂亮的阶梯图

    说到Python制图就不得不提matplotlib这个最为常用的库,matplotlib库作为Python经典的二维绘图库,在Python的数据可视化方面是最为常用的,今天呢,咱们接着上次和大家所探讨 ...

  10. python基础和第三方库 笔记(python基础完结包括高级用法,第三方库持续更新中...)

    python基础 注:本笔记面向有一定基础的人 本笔记是本人快速复习python过程中记录的,不适合零基础的人学习python的主工具,可以作为辅工具,本笔记记录了入门阶段常用操作,如有错误的地方,希 ...

最新文章

  1. 有监督学习的算法fit(x,y)传两个参数无监督学习的算法是fit(x),即传一个参数
  2. access 查找工龄大于30_ACCESS查询操作题完整
  3. 步步为营UML建模系列总结
  4. clickhouse 子查询_TPCDS用于Clickhouse和Doris性能测试
  5. 全志a64linux内核编译,Ubuntu16.04编译AndroidM(SoC:Allwinner A64)
  6. C51蜂鸣器和数码管动静态显示
  7. matlab amd补丁,Matlab升级 AMD锐龙性能恢复满血:轻松提升60%
  8. 【电路补习笔记】6、MOS管的参数与选型
  9. 【Python】mmSegmentation语义分割框架教程(自定义数据集、训练设定、数据增强)
  10. 更新 PORTS-Tree 且升级已安装的软件[zt]
  11. WeLink的杀手锏和远程办公软件的另一面
  12. POJ 3468 线段树+lazy标记
  13. Android远程过程通讯,Android系统进程间通信(IPC)机制Binder中的Client获得Server远程接口过程源代码分析(3)...
  14. skimage读取不到图片会报错 cv2读取不到图片返回None
  15. WPF 视频教程+笔记
  16. 如何委婉地拒绝公司的offer?
  17. 中景园0.96寸 OLED 显示屏 学习笔记
  18. mySQL数据库学习的一些心得
  19. ftp服务器软件 性能对比,常用ftp服务器软件介绍
  20. 除去工作赚到第一桶金10W+,我都做了哪些事儿?

热门文章

  1. GIMP小波分解处理照片
  2. android ios emoji兼容,web端怎么和移动端emoji表情兼容
  3. 三角形外接圆圆心 算法 删改版
  4. Bus Hound 软件实现长时间数据自动保存
  5. Himawari-8数据下载及命名
  6. 五子棋ai:极大极小搜索和α-β剪枝算法的思想和实现(qt和c++)(三)极大极小搜索和α-β剪枝算法
  7. 《数字货币与人民币国际化》读书笔记1
  8. HashMap底层原理详解
  9. 测绘地理信息标准规范汇总下载
  10. Java实现数组反转