OpenCV的calcHist
最近要计算图像的直方图,发现calcHist中的参数不是那么的一目了然,到网上搜了一下,资源还是比较多。
http://blog.csdn.net/ljbsdu/article/details/7412787这个哥们做的不错,为了方便在此转载过来。
函数说明如下:
void calcHist(const Mat*arrays, int narrays, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, boolaccumulate=false)
void calcHist(const Mat*arrays, int narrays, const int* channels, InputArray mask, SparseMat& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, boolaccumulate=false)
函数参数:
arrays – Source arrays. They all should have the same depth, CV_8U or CV_32F , and the same size. Each of them can have an arbitrary number of channels.
源输入(图像)数组,必须是相同深度的CV_8U或者CV_32F(即uchar或者float),相同大小,每一个可以是任意通道的;
narrays – Number of source arrays.
源输入数组中的元素个数;
channels – List of the dims channels used to compute the histogram. The first array channels are enumerated from 0 to arrays[0].channels()-1 , the second arraychannels are counted from arrays[0].channels() to arrays[0].channels() + arrays[1].channels()-1, and so on.
用来计算直方图的通道维数数组,第一个数组的通道由0到arrays[0].channels()-1列出,第二个数组的通道从arrays[0].channels()到arrays[0].channels()arrays[1].channels()-1以此类推;
mask – Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as arrays[i]. The non-zero mask elements mark the array elements counted in the histogram.
可选的掩膜,如果该矩阵不是空的,则必须是8位的并且与arrays[i]的大小相等,掩膜的非零值标记需要在直方图中统计的数组元素;
hist – Output histogram, which is a dense or sparse dims -dimensional array.
输出直方图,是一个稠密或者稀疏的dims维的数组;
dims – Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS (equal to 32 in the current OpenCV version).
直方图的维数,必须为正,并且不大于CV_MAX_DIMS(当前的OpenCV版本中为32,即最大可以统计32维的直方图);(统计的变量个数)
histSize – Array of histogram sizes in each dimension.
用于指出直方图数组每一维的大小的数组,即指出每一维的bin的个数的数组;(每维分成多少份)
ranges – Array of the dims arrays of the histogram bin boundaries in each dimension. When the histogram is uniform ( uniform =true), then for each dimension i it isenough to specify the lower (inclusive) boundary of the 0-th histogram bin and the upper(exclusive) boundary for the last histogram bin histSize[i]-1. That is,in case of a uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform ( uniform=false ), then each of ranges[i]contains histSize[i]+1 elements:. The array elements, that are not between and , are not counted in the histogram.
- 用于指出直方图每一维的每个bin(份)的上下界范围数组的数组,当直方图是均匀的(uniform =true)时,对每一维i指定直方图的第0个bin的下界(包含即[)L0和最 后一个即第histSize[i]-1个bin的上界(不包含的即))U_histSize[i]-1,也就是说对均匀直方图来说,每一个ranges[i]都是一个两个元素的数组【指出该维的上下界】。当直方图不是均匀的时,每一个ranges[i]数组都包含histSize[i]+1个元素:L0,U0=L1,U1=L1,...,U_histSize[i]-2 = L_histSize[i]-1,U_histSize[i]-1.不在L0到U_histSize[i]-1之间的数组元素将不会统计进直方图中;
uniform – Flag indicates that whether the histogram is uniform or not (see above).
直方图是否均匀的标志;【指定直方图每个bin统计的是否是相同数量的灰度级】
accumulate – Accumulation flag. If it is set, the histogram is not cleared in the beginning when it is allocated.This feature enables you to compute a single histogram from several sets of arrays, or to update the histogram in time.
-累加标志; [单幅图像不进行累计所以例子1中为false]
PS:对通道的单独说明:
首先dims是最终的直方图维数,narrays指出了arrays数组中图像的个数,其中每一幅图像都可以是任意通道的【只要最终dims不超过32即可】。
如果channels参数为0,则narrays和dims必须相等,否则弹出assert,此时计算直方图的时候取数组中每幅图像的第0通道。
当channels不是0的时候,用于计算直方图的图像是arrays中由channels指定的通道的图像,channels与arrays中的图像的对应关系,如channels的参数说明的,将arrays中的图像从第0幅开始按照通道摊开排列起来,然后channels中的指定的用于计算直方图的就是这些摊开的通道;假设有arrays中只有一幅三通道的图像image,那么narrays应该为1,如果是想计算3维直方图【最大也只能是3维的】,想将image的通道2作为第一维,通道0作为第二维,通道1作为第三维,则可以将channels设置为channesl={2,0,1};这样calcHist函数计算时就按照这个顺序来统计直方图。
可以看出channels不为0时narrays可以和dims不相等,只要保证arrays中至少有channels指定的通道就可以。
OpenCV的calcHist相关推荐
- 【Opencv】【C++】 Opencv之calcHist() 计算直方图
OpenCV 2.4.13 calcHist 通过图像计算直方图 函数声明如下: void calcHist( const Mat* images, int nimages,const int* ch ...
- 【opencv学习笔记】025之直方图计算 - calcHist函数详解
前言 如果你想了解更多有关于计算机视觉.OpenCV.机器学习.深度学习等相关技术的内容,想与更多大佬一起沟通,那就扫描下方二维码加入我们吧! 1.calcHist函数是干什么滴? 这个问题嘛,看看标 ...
- OpenCV 图像直方图计算calcHist()
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/keith_bb/article/details/56680997 图像直方图是对数据集合的一种统计方 ...
- 【OpenCV 】直方图均衡化,直方图计算,直方图对比
目录 1.直方图均衡化¶ 1.1 原理 1.2 直方图均衡化 1.3 直方图均衡化原理 1.4 代码实例 1.5 运行效果 2. 直方图计算¶ 2.1 目标 2.2 直方图 2.3 代码实例 2.4 ...
- OpenCV之imgproc 模块. 图像处理(4)直方图均衡化 直方图计算 直方图对比 反向投影 模板匹配
直方图均衡化 目标 在这个教程中你将学到: 什么是图像的直方图和为什么图像的直方图很有用 用OpenCV函数 equalizeHist 对图像进行直方图均衡化 原理 图像的直方图是什么? 直方图是图像 ...
- 基于Python+OpenCV的图像搜索引擎(CBIR+深度学习+机器视觉)含全部工程源码及图片数据库下载资源
目录 前言 总体设计 系统整体结构图 系统流程图 运行环境 模块实现 1. 数据预处理 2. 定义图像描述符 3. 索引化数据集 4. 设计搜索引擎内核 5. 执行搜索 系统测试 1. 处理数据集 2 ...
- opencv——图像直方图与反向投影
引言 在图像处理中,对于直方图这个概念,肯定不会陌生.但是其原理真的可以信手拈来吗? 本文篇幅有点长,在此列个目录,大家可以跳着看: 分析图像直方图的概念,以及opencv函数calcHist()对于 ...
- calcHist函数
1.calcHist函数 函数作用: calcHist函数来计算图像直方图 2.calcHist函数调用形式 C++:void calcHist(const Mat* images, int nim ...
- opencv-python基础知识学习笔记
opencv-python基础知识学习笔记 原博地址:https://www.cnblogs.com/silence-cho/p/10926248.html 目录: opencv-python基础知识 ...
最新文章
- Visual Studio 2008/2010中Xaml开发格式设置技巧
- HTML DOM教程 21-HTML DOM Event 对象
- ubuntu 64 12.04 oracle,ubuntu server 12.04 x86_64 下安装oracle xe 11 x86_64
- 在Asp.net网页中使用接口
- win10用Eclipse+OpenJTag对S3C2440开发板进行动态调试
- php如何生成本地文档,php如何生成word文件
- java接口自动化demo_第一个java 接口自动化程序
- rtsp 报文转发_rtsp_proxy_server
- Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined)
- hdu 1818 It's not a Bug, It's a Feature!(位运算+bfs优先队列)
- 拉勾教育管理系统(前端)
- 163邮箱手机收件服务器设置,网易邮箱全面默认开通IMAP 手机收信提速10倍
- 简述关于ASP.NET MVC与.NET CORE 的区别
- OpenTracing 详解
- 计算机软考论文网络真题,2017上半年软考中级信息系统项目管理师真题论文
- SQL Native Client][SQL Server]无法将函数单元 'sp_sqlagent_get_startup_info' 添加到组件 'Agen...
- 超硬核Python避坑学习方案奉上!入门到就业一篇就搞定!
- Element组件(input输入框)
- 几种swf格式视频转换器简介
- 小米手环深圳通服务器维护,小米手环3 NFC版上手:手机刷公交卡的日子一去不复返了...
热门文章
- 【计算机视觉】Lecture 11:LoG和DoG滤波算子
- 用智能ABC关闭程序
- 计算机word知识试题及答案,全国计算机等级考试Word试题及答案(2)
- 群晖NAS 7.X版搭建博客网站,并内网穿透发布公网可访问 4-8
- CentOS8部署多版本共存Python开发环境
- java的行业认证_Sun认证Java程序员考试介绍
- BeautifulSoup的高级应用 之 find findAll
- 输入一个字符串转换成十进制整数
- Docker - Docker Container及Container命令详解
- .jar!/BOOT-INF/classes!/ jar包无法重启了,求大神帮忙解答,谢谢!