我试图在

python中实现自适应直方图均衡.我拍摄一张图像并将其分割成较小的区域,然后将传统的直方图均衡应用于它.然后我将较小的图像合并为一个并获得最终的合成图像.最终图像在性质上看起来非常块状,并且对于每个单独的区域具有不同的对比度水平.有没有办法可以保持每个单独图像的均匀对比度,使其看起来像单个图像而不是缝合在一起的较小图像.

import cv2

import numpy as np

from matplotlib import pyplot as plt

from scipy.misc import imsave

from scipy import ndimage

from scipy import misc

import scipy.misc

import scipy

import image_slicer

from image_slicer import join

from PIL import Image

img = 'watch.png'

num_tiles = 25

tiles = image_slicer.slice(img, num_tiles)

for tile in tiles:

img = scipy.misc.imread(tile.filename)

hist,bins = np.histogram(img.flatten(),256,[0,256])

cdf = hist.cumsum()

cdf_normalized = cdf *hist.max()/ cdf.max()

plt.plot(cdf_normalized, color = 'g')

plt.hist(img.flatten(),256,[0,256], color = 'g')

plt.xlim([0,256])

plt.legend(('cdf','histogram'), loc = 'upper left')

cdf_m = np.ma.masked_equal(cdf,0)

cdf_o = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())

cdf = np.ma.filled(cdf_o,0).astype('uint8')

img3 = cdf[img]

cv2.imwrite(tile.filename,img3)

tile.image = Image.open(tile.filename

image = join(tiles)

image.save('watch-join.png')

python直方图均衡函数_Python中的自适应直方图均衡相关推荐

  1. python local函数_python中的函数

    函数 一.函数的定义 def是可执行的代码.def创建了一个对象并将其赋值给某一变量名.def语句是实时执行的,即:def在运行时才进行评估,而在def之中的代码在函数调用后才会评估.函数本身就是一个 ...

  2. python sep函数_Python中带有print()函数的sep参数

    python sep函数 sep parameter stands for separator, it uses with the print() function to specify the se ...

  3. python dump函数_python中实现php的var_dump函数功能

    最近在做python的web开发(原谅我的多变,好东西总想都学着...node.js也是),不过过程中总遇到些问题,不管是web.py还是django,开发起来确实没用php方便,毕竟存在的时间比较短 ...

  4. python round函数_python中round函数如何使用

    round函数很简单,对浮点数进行近似取值,保留几位小数.比如 >>> round(10.0/3, 2) 3.33 >>> round(20/7) 3 第一个参数是 ...

  5. python remove函数_python中remove函数的用法是什么?

    python中remove函数的用法是什么? python中remove函数的用法: 描述 remove() 函数用于移除列表中某个值的第一个匹配项. 语法 remove()方法语法: list.re ...

  6. python array函数_Python 中的range()函数与array()函数

    我们在Python中存在一个非常好用的range()与array()函数,下面作用法简要介绍. 一.range()函数 >>> range(1,10) -->不包括10 [1, ...

  7. python有趣函数_python中有趣的函数

    filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决 ...

  8. python shape函数_Python中的多态及抽象类

    本书同名免费MOOC<Python编程基础及应用>在哔哩哔哩(B站)热播,作者带着你学. 版权声明:本文内容引用自作者的图书<Python编程基础及应用>(高等教育出版社).本 ...

  9. python defaultdict函数_Python中defaultdict与lambda表达式用法

    这篇文章主要介绍了Python中defaultdict与lambda表达式用法,在这里分享给大家,需要的朋友可以参考下 本文实例讲述了Python中defaultdict与lambda表达式用法.分享 ...

最新文章

  1. C++ 内存泄漏检测:valgrind和AddressSanitizer
  2. (0045) iOS 开发之MBProgressHUD 源码学习
  3. porphet论文_时间序列模型Prophet使用详细讲解
  4. 怎么把一个控件放到tab页面上去?_移动端页面内容切换
  5. POJ 2195 Going Home 二分图的最大权匹配
  6. LeetCode 279 完全平方数
  7. Linux——Windows连接CentOS XRDP 错误信息(login failed for display 0)
  8. menu什么意思中文意思_英文alone、lonely、lonesome 中文意思跟用法差别
  9. matlab线性平面映射求通项_代数学发展史: 线性空间
  10. 1w存银行一年多少利息_利息能拿上万?银行行长:20万存款这样存,一年躺着白白赚一万!...
  11. spring boot高性能实现二维码扫码登录(中)——Redis版
  12. C++Qt笔记-完美屏蔽IDEA中accept2弹窗(无需重装软件、无需重装系统)
  13. ionic2/cordova自定义插件集成aar包
  14. php定位和天气,基于thinkphp实现根据用户ip判断地理位置并提供对应天气信息的应用_PHP教程...
  15. ExtJS ComboBox同时加载远程和本地数据
  16. 2FSK在瑞利衰落信道下的相干与非相干解调误码率-MATLAB基带仿真
  17. 电子商务中与客户沟通宝典
  18. 3分钟教你如何在Word里快速制作单斜线和多斜线表头
  19. C#操作Word:删除指定页(缺陷无法根据内容删除,只能固定页码;Microsoft.Office.Interop.Word.dll应用)
  20. view路由传参方法

热门文章

  1. 架构师究竟要不要写代码?
  2. 答应我!别再写上千行的类了,好吗?
  3. Java 中几种获取文件路径的方式
  4. Spring Boot + Redis 实现接口幂等性 | 分布式开发必知!
  5. 自己写分布式配置中心(上篇)- 单机模式
  6. java 圈复杂度_关于Java:降低Switch语句的循环复杂度-Sonar
  7. opencv 保存读取mat
  8. python 透视变换补边
  9. cudnn.benchmark
  10. layui table 设置滚动条