绘制直方图

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.2Histogram 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 pltfrom skimage import data
from skimage import exposure
from skimage.exposure import match_histogramsreference = 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()

实验输出


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

  1. python库skimage 图像直方图均衡化、自适应均衡化、对比度拉伸实现

    直方图全局均衡化 from skimage import exposure # Equalization img_eq = exposure.equalize_hist(img) 直方图自适应均衡化 ...

  2. python库skimage 绘制二值图像的凸壳

    二值图像的凸壳指的是包围输入二值图像白色区域的最小的凸多边形的像素集合. skimage中的函数 from skimage.morphology import convex_hull_image ch ...

  3. python库skimage 图像直方图局部均衡化

    函数 from skimage import exposure from skimage.morphology import disk from skimage.filters import rank ...

  4. python库skimage 将针对灰度图像的滤波器用于RGB图像

    有许多滤波器设计用于灰度图像但是不能用于彩色图像.为了简化创建函数,使其能够用于RGB图像,scikit-image图像处理库提供了adapt_rgb装饰器. 实际使用adapt_rgb装饰器,你必须 ...

  5. python库skimage 常值轮廓寻找并标记

    我们使用行进正方形方法找到图像中的常值轮廓 函数: #Find contours at a constant value of 0.8 contours = measure.find_contours ...

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

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

  7. python 库画小动物大全_python库之turtle(图形绘制) 开启新的快乐源泉

    Python Python开发 Python语言 python库之turtle(图形绘制) 开启新的快乐源泉 相信有不少人学习python 都是听了老前辈的推荐 "学python好,pyth ...

  8. Python绘制图像的灰度直方图、累计直方图

    在计算机视觉中,对图像进行预处理时经常会用到图像的直方图.累计直方图等.下面给出一种参考代码,用python绘制图像灰度直方图和累计直方图. # -*- coding: utf-8 -*- " ...

  9. python hist直方图拟合曲线_详解用Python为直方图绘制拟合曲线的两种方法

    直方图是用于展示数据的分组分布状态的一种图形,用矩形的宽度和高度表示频数分布,通过直方图,用户可以很直观的看出数据分布的形状.中心位置以及数据的离散程度等. 在python中一般采用matplotli ...

最新文章

  1. jmeter实现多并发
  2. 边缘计算 — 与 5G
  3. Ruby的资源站点和开发工具列表
  4. 【控制】《鲁棒控制-线性矩阵不等式处理方法》-俞立老师-第9章-时滞系统的分析和综合
  5. 【存储知识学习】第二章存走进计算机IO世界--《大话存储》阅读笔记
  6. 吴恩达机器学习006分类问题
  7. php 进程函数,php多进程函数
  8. k8s往secret里导入证书_k8s中secret解析
  9. pkuseg-python的postag.zip在不能联网的服务器上的解决办法
  10. 稀疏矩阵的压缩存储--十字链表(转载)
  11. HTTP状态码表格汇总
  12. 打不开/dev/vmmon:断裂管道_湖北加工管道式自卸除铁器厂家询价咨询_国凯环保设备...
  13. 使用Entity Framework Core,Swagger和Postman创建ASP.NET Core Web API的分步指南
  14. 数据库系统概论第五版(第 4 章 数据库安全性)笔记
  15. 支付宝怎么看银行卡号?支付宝查询银行卡号仅需3步
  16. office 365 获取会议室日历
  17. python解析excel文件多级标题嵌套行
  18. HDMI 收发器简化家庭影院系统设计
  19. 21世纪,黑客是这样抢银行的
  20. INSERT INTO 小技巧

热门文章

  1. python适合自学编程吗-孩子学编程选Scratch还是Python
  2. python电脑下载-Python3.9官方下载
  3. 没有基础的人可以学python吗-无基础可以学习Python吗?
  4. 车载语音最新黑科技 除了辨“音”还会识“相”
  5. 【深度优先搜索】LeetCode77:组合
  6. FFMPEG结构体分析:AVFormatContext
  7. 基于Socket的文件传输(使用CSocket类)
  8. mysql大表数据抽取_从云数据迁移服务看MySQL大表抽取模式
  9. java 排序stackoverflow_爬取 100 万条 StackOverflow 问答后,我得出的结论!
  10. ajax hacking,Ajax Hacking