python 直方图hist
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
sys.path.append('/usr/lib/python2.7/dist-packages')
import matplotlib.pyplot as plt
import argparse
import utils
import cv2
import numpy as np def calcAndDrawHist(image, color):
hist= cv2.calcHist([image], [0], None, [256], [0.0,255.0])
minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(hist)
histImg = np.zeros([256,256,3], np.uint8)
hpt = int(0.9* 256); for h in range(256):
intensity = int(hist[h]*hpt/maxVal)
cv2.line(histImg,(h,256), (h,256-intensity), color) return histImg; if __name__ == '__main__':
img = cv2.imread("c.jpg")
b, g, r = cv2.split(img) histImgB = calcAndDrawHist(b, [255, 0, 0])
histImgG = calcAndDrawHist(g, [0, 255, 0])
histImgR = calcAndDrawHist(r, [0, 0, 255]) cv2.imshow("histImgB", histImgB)
cv2.imshow("histImgG", histImgG)
cv2.imshow("histImgR", histImgR)
cv2.imshow("Img", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
python 直方图hist的更多相关文章
- python——直方图均衡化
		
from PIL import Image from pylab import * from numpy import * def histeq(im,nbr_bins = 256): "& ...
 - 频率直方图(hist)
		
频率直方图(frequency histogram)亦称频率分布直方图.统计学中表示频率分布的图形.在直角坐标系中,用横轴表示随机变量的取值,横轴上的每个小区间对应一个组的组距,作为小矩形的底边:纵轴 ...
 - python 直方图
		
import matplotlib.pyplot as plt import numpy as np pop = np.random.randint(0,100,100) pop n,bins,pat ...
 - Python交互图表可视化Bokeh:5 柱状图| 堆叠图| 直方图
		
柱状图/堆叠图/直方图 ① 单系列柱状图② 多系列柱状图③ 堆叠图④ 直方图 1.单系列柱状图 import numpy as np import pandas as pd import matplo ...
 - 《Python数据可视化编程实战》
		
第一章:准备工作环境 WinPython-32bit-3.5.2.2Qt5.exe 1.1 设置matplotlib参数 配置模板以方便各项目共享 D:\Bin\WinPython-32bit-3.5 ...
 - python 数据可视化(matplotlib)
		
matpotlib 官网 :https://matplotlib.org/index.html matplotlib 可视化示例:https://matplotlib.org/gallery/inde ...
 - 70个注意的Python小Notes
		
Python读书笔记:70个注意的小Notes 作者:白宁超 2018年7月9日10:58:18 摘要:在阅读python相关书籍中,对其进行简单的笔记纪要.旨在注意一些细节问题,在今后项目中灵活运用 ...
 - Python模块简介及安装 [numpy,pandas,matplotlib,scipy,statsmodels,Gensim,sklearn,keras]
		
https://pan.baidu.com/s/1bpVv3Ef 67bd 模块安装文件下载地址 pip install "numpy-1.12.0b+mkl-cp35- ...
 - Python pandas & numpy 笔记
		
记性不好,多记录些常用的东西,真·持续更新中::先列出一些常用的网址: 参考了的 莫烦python pandas DOC numpy DOC matplotlib 常用 习惯上我们如此导入: impo ...
 
随机推荐
- git stash命令使用手册
			
修改记录压栈保存: git stash push -u -m "msg" // -u ~ --意思是包含未被跟踪的文件git stash push -m "msg&quo ...
 - Select查询语句1
			
一.语法结构 select[all|distinct]select_list from table_name[join join_condition] where search_condition g ...
 - 【LOJ】#2269. 「SDOI2017」切树游戏
			
题解 把所有的数组一开始就FWT好然后再IFWT回去可以减小常数 从13s跑到0.7s-- 可以参照immortalCO的论文,感受一下毒瘤的动态动态DP 就是用数据结构维护线性递推的矩阵的乘积 由于 ...
 - 使用Sublime Text 3的HTML-CSS-JS Prettify插件格式化代码
			
很多时候,我们想要格式化HTML-CSS-JS代码,网站上有很多实现此功能的小工具,当然,我的网站首页也有.但是,如果我们的代码编辑器上面也有这样的功能,那不是更加快速便捷?So,接下来,我们看看Su ...
 - Spring拦截器和过滤器
			
什么是拦截器 拦截器(Interceptor): 用于在某个方法被访问之前进行拦截,然后在方法执行之前或之后加入某些操作,其实就是AOP的一种实现策略.它通过动态拦截Action调用的对象,允许开发者 ...
 - 003.RAID管理
			
一 查看RAID组信息 [root@kauai ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Mon Aug 29 22: ...
 - Linux-c系统编程
			
进程相关的概念 程序和进程 程序:二进制文件.占用磁盘空间 进程:运行着的程序,数据在内存中,占用系统资源,CPU,物理内存() PCB描述进程(进程控制块) 把描述进程的所有信息的那条记录叫做 PC ...
 - 关于dubbo和zookeeper 注册中心
			
Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何API侵入,只需用Spring加载Dubbo的配置即可,Dubbo基于Spring的Schema扩展进行加载.如果不想使用Sprin ...
 - 喵哈哈村的魔法考试 Round #2 (Div.2) 题解
			
喵哈哈村的魔法考试 Round #2 (Div.2) 题解 A.喵哈哈村的战争 题解: 这道题就是for一遍,统计每个村子的战斗力的和,然后统计哪个村子的战斗力和大一点就好了. 唯一的坑点,就是这道题 ...
 - C# 读取CSV和EXCEL文件示例
			
我们习惯了直接连到数据库上面读取数据表的数据内容: 如果有一天我们需要读取CSV,EXCEL文件的内容的时候,可不可以也像读数据表的方式一样呢?当然可以,使用OleDB ADO.NET是很简单的事情 ...