绘制直方图

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. CompletableFuture CompletableFuture.supplyAsync 异常处理
  2. 10601 - Cubes(Ploya)
  3. 你的响应阻塞了没有?--Spring-WebFlux源码分析
  4. git提交屏蔽某java类_git 删除某次指定的提交
  5. linux内核epub,Android底层开发技术实战详解——内核、移植和驱动(第2版)[EPUB][MOBI][AZW3][42.33MB]...
  6. 怎么开通手机信息服务器,如何用手机建立网站
  7. pytest.5.参数化的Fixture
  8. 读光OCR-文字识别技术解读与应用案例分析
  9. Android WebView重定向问题的解决方案
  10. C Traps:运算
  11. 基于springboot的高校档案系统
  12. 三菱伺服驱动器示例_三菱伺服电机伺服驱动器
  13. 嵌入式C语言知识总结
  14. Ubuntu软件商店下载速度慢
  15. java docx 文档不可编辑、复制
  16. 白盒测试:三角形问题实验报告
  17. Windows远程提示“终端服务器超出了最大允许连接”
  18. Vue路由管理(菜单列表)
  19. 东方博宜OJ 1863 - 【入门】特殊的数字四十
  20. 图片怎么转换成pdf格式?这几个方法帮你一键转换

热门文章

  1. 自学python考哪些证书-给零基础学习Python的小伙伴的四个建议
  2. python安装-Python安装
  3. 联想17TV语音遥控教程 语音点播更方便
  4. 离线语音控制并不等于本地语音识别
  5. 前沿 | IBM语音识别已接近人类水平
  6. 自动语音识别的原理是什么,它的作用是什么
  7. echarts 折线图数据太多会导致卡顿_重新定义数据图表,还有比这个更厉害的吗?...
  8. Axure的一些入门小案例
  9. 8192 oracle,ORA-39095: 转储文件空间已耗尽: 无法分配 8192 字节
  10. 【深度优先搜索】20行代码解决8皇后问题