函数

from skimage import exposure
from skimage.morphology import disk
from skimage.filters import rank
# Global equalize
img_rescale = exposure.equalize_hist(img)# Local Equalization
selem = disk(30)
img_eq = rank.equalize(img, selem=selem)

实验:低对比度图像全局均衡化和局部均衡化

"""
============================
Local Histogram Equalization
============================This example enhances an image with low contrast, using a method called *local
histogram equalization*, which spreads out the most frequent intensity values
in an image.The equalized image has a roughly linear cumulative distribution function
for each pixel neighborhood.The local version of the histogram equalization emphasized every local
graylevel variations."""
import numpy as np
import matplotlib
import matplotlib.pyplot as pltfrom skimage import data
from skimage.util.dtype import dtype_range
from skimage.util import img_as_ubyte
from skimage import exposure
from skimage.morphology import disk
from skimage.filters import rankmatplotlib.rcParams['font.size'] = 9def plot_img_and_hist(image, axes, bins=256):"""Plot an image along with its histogram and cumulative histogram."""ax_img, ax_hist = axes# Make and return a second axes that shares the x-axis. # The new axes will overlay ax (or the current axes if ax is None), and its ticks will be on the right.ax_cdf = ax_hist.twinx()# Display imageax_img.imshow(image, cmap=plt.cm.gray)ax_img.set_axis_off()# Display histogramax_hist.hist(image.ravel(), bins=bins)# Change the ScalarFormatter used by default for linear axes.ax_hist.ticklabel_format(axis='y', style='scientific', scilimits=(0, 0))ax_hist.set_xlabel('Pixel intensity')xmin, xmax = dtype_range[image.dtype.type]ax_hist.set_xlim(xmin, xmax)# Display cumulative distributionimg_cdf, bins = exposure.cumulative_distribution(image, bins)ax_cdf.plot(bins, img_cdf, 'r')return ax_img, ax_hist, ax_cdf# Load an example image
img = img_as_ubyte(data.moon())# Global equalize
img_rescale = exposure.equalize_hist(img)# Equalization
selem = disk(30)
img_eq = rank.equalize(img, selem=selem)# Display results
fig = plt.figure(figsize=(8, 5))
axes = np.zeros((2, 3), dtype=np.object)
axes[0, 0] = plt.subplot(2, 3, 1)
axes[0, 1] = plt.subplot(2, 3, 2, sharex=axes[0, 0], sharey=axes[0, 0])
axes[0, 2] = plt.subplot(2, 3, 3, sharex=axes[0, 0], sharey=axes[0, 0])
axes[1, 0] = plt.subplot(2, 3, 4)
axes[1, 1] = plt.subplot(2, 3, 5)
axes[1, 2] = plt.subplot(2, 3, 6)ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0])
ax_img.set_title('Low contrast image')
ax_hist.set_ylabel('Number of pixels')ax_img, ax_hist, ax_cdf = plot_img_and_hist(img_rescale, axes[:, 1])
ax_img.set_title('Global equalise')ax_img, ax_hist, ax_cdf = plot_img_and_hist(img_eq, axes[:, 2])
ax_img.set_title('Local equalize')
ax_cdf.set_ylabel('Fraction of total intensity')# prevent overlap of y-axis labels
fig.tight_layout()
plt.show()

实验结果

python库skimage 图像直方图局部均衡化相关推荐

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

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

  2. python库skimage 绘制直方图;绘制累计直方图;实现直方图匹配(histogram matching)

    绘制直方图 from skimage import exposure # 绘制彩色图像的c通道的直方图 img_hist, bins = exposure.histogram(img[..., c], ...

  3. python绘制灰度图片直方图-python数字图像处理实现直方图与均衡化

    在图像处理中,直方图是非常重要,也是非常有用的一个处理要素. 在skimage库中对直方图的处理,是放在exposure这个模块中. 1.计算直方图 函数:skimage.exposure.histo ...

  4. 【Python OpenCV】图像直方图 calcHist方法 equalizeHist方法

    [Python OpenCV]图像直方图 calcHist方法 equalizeHist方法 (一)图像直方图 图像的构成是有像素点构成的,每个像素点的值代表着该点的颜色(灰度图或者彩色图).所谓直方 ...

  5. 【opencv学习】【图像直方图和均衡化】

    今天学习图像直方图和图像均衡化 一:图像直方图 import cv2 import numpy as np import matplotlib.pyplot as plt# 图像的直方图,就是统计哪些 ...

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

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

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

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

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

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

  9. python---(2)Python库资源大全

    转载地址:https://zhuanlan.zhihu.com/p/27350980 本文是一个精心设计的Python框架.库.软件和资源列表,是一个Awesome XXX系列的资源整理,由BigQu ...

最新文章

  1. jQuery中排除指定元素,同时选择剩下的所有元素
  2. 即插即用 | S-FPN全新的金字塔网络,更适合轻量化模型的FPN
  3. 冲杯咖啡,谈谈计算机cpu
  4. 20162318 2018-2019-2《网络对抗技术》Exp1 PC平台逆向破解
  5. SQL Server 2008之DMF
  6. 到底什么是API经济
  7. wikipedia_教职员工可以通过Wikipedia进行教学吗?
  8. 洛希极限 (10 分)
  9. Log Explorer 使用简介转
  10. 谈谈javascript中原型继承
  11. lightning接口_苹果、安卓充电接口有望统一,欧盟重压下,苹果将不得不妥协
  12. MyBatis官方文档——Java API部分
  13. linux nginx rtmp 直播,linux下利用nginx搭建rtmp直播服务
  14. ubuntu更改ip地址 网官 dns,使ubuntu的ip地址每次启动都是固定
  15. 方正璞华“劳动人事法律自助咨询服务平台”在武汉武昌区投入使用!
  16. PID tuning guide
  17. 内部资料泄密,电信拨号软件系最大流氓软件
  18. RK3588平台开发系列讲解(USB篇)USB 外设 CONFIG
  19. 老版本微信平台服务器部署步骤(没那么坑版)
  20. 汇编语言----处理机控制指令及伪指令

热门文章

  1. python爬虫教程-Python爬虫五大零基础入门教程
  2. 30岁学python有前途吗-为什么做大数据一定要学Python?
  3. LD3320的嵌入式语音识别系统的应用
  4. 有道口语大师APP评测:语音识别准确度低
  5. 人工智能感知技术是机器人应用支撑技术之一
  6. 智能手机的超性能语音识别技术简介
  7. automake 框架_[]GNU_Automake_中文.pdf
  8. grafana zabbix 模板_【Grafana教程】安装Grafana并配置Zabbix数据源
  9. 主机mysql密码修改_mysql密码修改方法_配置root密码_mysql 改数据库名_mysql忘记密码...
  10. flex实现水平垂直居中