python gamma函数_python gamma矫正
这个函数,主要用来做对比度调整,利用 gamma 曲线 或者 log 函数曲线,
gamma 函数的表达式: y=xγ, 其中, x 是输入的像素值,取值范围为 [0−1], y 是输出的像素值,通过调整γ 值,改变图像的像素值的分布,进而改变图像的对比度。 log 函数的表达式: y=alog(1+x), a 是一个放大系数,x 同样是输入的像素值,取值范围为 [0−1], y 是输出的像素值。 inverse log 的表达式: y=a(2x−1), 这些变换都是从 [0−1] 变到 [0−1] 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88""" ================================= Gamma and log contrast adjustment ================================= This example adjusts image contrast by performing a Gamma and a Logarithmic correction on the input image. """
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from skimage import data, img_as_float
from skimage import exposure
matplotlib.rcParams['font.size'] = 8
def plot_img_and_hist(img, axes, bins=256):
"""Plot an image along with its histogram and cumulative histogram. """
img = img_as_float(img)
ax_img, ax_hist = axes
ax_cdf = ax_hist.twinx()
# Display image
ax_img.imshow(img, cmap=plt.cm.gray)
ax_img.set_axis_off()
# Display histogram
ax_hist.hist(img.ravel(), bins=bins, histtype='step', color='black')
ax_hist.ticklabel_format(axis='y', style='scientific', scilimits=(0, 0))
ax_hist.set_xlabel('Pixel intensity')
ax_hist.set_xlim(0, 1)
ax_hist.set_yticks([])
# Display cumulative distribution
img_cdf, bins = exposure.cumulative_distribution(img, bins)
ax_cdf.plot(bins, img_cdf, 'r')
ax_cdf.set_yticks([])
return ax_img, ax_hist, ax_cdf
# Load an example image
img = data.moon()
# Gamma
gamma_corrected = exposure.adjust_gamma(img, 2)
# Logarithmic
logarithmic_corrected = exposure.adjust_log(img, 1)
# Display results
fig = plt.figure(figsize=(8, 5))
axes = np.zeros((2, 3), dtype=np.object)
axes[0, 0] = plt.subplot(2, 3, 1, adjustable='box-forced')
axes[0, 1] = plt.subplot(2, 3, 2, sharex=axes[0, 0], sharey=axes[0, 0],
adjustable='box-forced')
axes[0, 2] = plt.subplot(2, 3, 3, sharex=axes[0, 0], sharey=axes[0, 0],
adjustable='box-forced')
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')
y_min, y_max = ax_hist.get_ylim()
ax_hist.set_ylabel('Number of pixels')
ax_hist.set_yticks(np.linspace(0, y_max, 5))
ax_img, ax_hist, ax_cdf = plot_img_and_hist(gamma_corrected, axes[:, 1])
ax_img.set_title('Gamma correction')
ax_img, ax_hist, ax_cdf = plot_img_and_hist(logarithmic_corrected, axes[:, 2])
ax_img.set_title('Logarithmic correction')
ax_cdf.set_ylabel('Fraction of total intensity')
ax_cdf.set_yticks(np.linspace(0, 1, 5))
# prevent overlap of y-axis labels
fig.tight_layout()
plt.show()
python gamma函数_python gamma矫正相关推荐
- python怎么用gamma函数_「gamma函数」Gamma函数 - seo实验室
gamma函数 伽玛函数(Gamma函数),也叫欧拉第二积分,是阶乘函数在实数与复数上扩展的一类函数.该函数在分析学.概率论.偏微分方程和组合数学中有重要的应用.与之有密切联系的函数是贝塔函数,也叫第 ...
- python zip函数_Python zip()函数
python zip函数 Good day learners, hope that you are doing well. We discussed about Python Modulo in ou ...
- [转载] python radians函数_Python numpy.radians() 使用实例
参考链接: Python中的numpy.cos The following are code examples for showing how to use . They are extracted ...
- python factorial函数_Python 阶乘factorial
整数的阶乘(factorial)是所有小于及等于该数的正整数的积,0的阶乘为1.即:n!=1×2×3×...×n. import numpy as np import matplotlib as mp ...
- python not函数_python 函数
1 为什么使用函数 在没有接触函数时,有时候需要将一个功能多次写,如果需要修改其中一个变量,则需要把所有实现该功能的代码一处一处改.不利于代码维护,代码量大了,组织结构也会很不清晰. 所以总结不使用函 ...
- python include函数_python 库函数
python的内建函数和库函数的区别是什么? [区别]:标准库函数都需要import xxx才能取得.内建函数都在__builtins__里面,在global里直接就能用. [补充]:1.python ...
- python islower函数_python字符串是否是小写-python 字符串小写-python islower函数-python islower函数未定义-嗨客网...
Python字符串是否是小写教程 在开发过程中,有时候我们需要判断一个 Python islower()函数详解 语法 str.islower() -> bool 参数 参数 描述 str 表示 ...
- python agg函数_Python Pandas Series.agg()用法及代码示例
Python是进行数据分析的一种出色语言,主要是因为以数据为中心的python软件包具有奇妙的生态系统. Pandas是其中的一种,使导入和分析数据更加容易. Pandas Series.agg()用 ...
- python findall函数_python正则表达式之中的findall函数是什么?
在这篇文章之中我们来了解一下关于python正则表达式的相关知识,有些朋友可能是刚刚接触到python这一编程语言,对这一方面不是特别的了解,在接下来这篇文章将会来带大家来了解关于正则表达式中的pyt ...
最新文章
- DaemonSet 典型应用场景 - 每天5分钟玩转 Docker 容器技术(129)
- 特来电CMDB应用实践
- Android 经典欧美小游戏 guess who
- mysql.user表中Host为%的含义
- apxs php5,安装PHP5和PHP7
- 永不丢失照片:防弹照片备份的完整指南
- 关于延长物联网设备的生命周期
- html 拖拽坐标,Html+css实现拖拽导航条
- dir612路由器虚拟服务器设置,dir612虚拟服务器设置
- vue 3.x 中全局配置 axios
- 赵容弼(Cho Yong Pil) -《30周年纪念专辑》
- html不用画布太阳系示意图,html5-canvas-太阳系2
- 电脑启动卡、慢,运行起来后,可能可以慢慢恢复正常问题的原因和解决方案
- linux之系统间的文件传输(scp,rsync以及二者之间的区别)
- 解决127.0.0.1 已拒绝连接的方法
- numpy之多维数组
- 【贪心策略】区间选点问题
- Oracle在采购部增加一名员工,ORACLEEBS采购功能点操作手册1.doc
- Jenkins使用2——Jenkins使用时间戳
- excel组合汇总_Excel汇总20160229
热门文章
- c++ stl stack_C ++ STL中的stack :: push()函数
- Xamarin开发笔记—百度在线语音合成
- JSON.stringify转换Date不正确的解決方法
- Oracle11完全卸载方法
- 手把手带你玩转Tensorflow 物体检测 API (4)—— 模型验证
- Shiro并发登录人数控制遇到的问题和解决
- uniapp+typeScript+vue3.0+vite
- qt 5编程入门(第2版)_《C++并发编程实战第2版》第六章:设计基于锁的并发数据结构(1/3)...
- 计算机的iscsi配置,我们将了解如何设置自己的支持iscsi配置的存储节点
- python数据库自动重连_python mysql断开重连的实现方法