calcHist() 函数有 3 个构造函数

第一个构造函数:

calcHist() [1/3]
void cv::calcHist   (   const Mat *     images,
int     nimages,
const int *     channels,
InputArray  mask,
OutputArray     hist,
int     dims,
const int *     histSize,
const float **  ranges,
bool    uniform = true,
bool    accumulate = false
)

参数说明:

images
一组图片数据,需要有相同的位深,相同的尺寸大小。但是通道数可以不同。
Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same size. Each of them can have an arbitrary number of channels.

nimages
该组图片的数量。
Number of source images.

channels
通道列表,对应每张图片选择那个通道进行直方图的计算。
List of the dims channels used to compute the histogram. The first array channels are numerated from 0 to images[0].channels()-1 , the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.

mask
可选。尺寸和图片尺寸相同,位深 8-bit。掩膜内非 0 元素对应的区域会被统计进直方图。
Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i] . The non-zero mask elements mark the array elements counted in the histogram.

hist
输出直方图
Output histogram, which is a dense or sparse dims -dimensional array.

dims
直方图的维度数量。比较常见的统计一个通道的直方图,会设置成 1。最大值为 32,即 OpenCV 中纬度最大值。
Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS (equal to 32 in the current OpenCV version).

histSize
直方图尺寸。直方图在每一个维度上的大小。即在某个维度上分段个数,如果把 0~255 每个像素分成一段,那总共有 256 段,该值为 256。
Array of histogram sizes in each dimension.

ranges
每个维度上的边界。histSize确定的是分割成几段,ranges确定的是选择范围。比如上面分成了 256 段,ranges 设置成 [0, 255] 即可。注意这里的数据类型有 2 个 * 号,表示这是一个数组的数组,可以理解为 [[0, 255], [0, 255], [1, 254]...] 这样的形式。
如果histSize设置成 256,ranges 设置成 [0, 50],会增加很多 0 的插值,为了把 51 个灰阶分成 256 段。
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 is enough to specify the lower (inclusive) boundary L0 of the 0-th histogram bin and the upper (exclusive) boundary UhistSize[i]−1 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: L0,U0=L1,U1=L2,…,UhistSize[i]−2=LhistSize[i]−1,UhistSize[i]−1 . The array elements, that are not between L0 and UhistSize[i]−1 , are not counted in the histogram.

uniform
数据一致的标志位。当为 true 的时候,ranges 的范围是 0 ~ histSize-1。
Flag indicating whether the histogram is uniform or not (see above).

accumulate
用于从多个图片数组计算直方图的标志位,有迭代跟新效果。通常设置为 false。
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.

第二个构造函数:

void cv::calcHist    (   const Mat *     images,
int     nimages,
const int *     channels,
InputArray  mask,
SparseMat &     hist,
int     dims,
const int *     histSize,
const float **  ranges,
bool    uniform = true,
bool    accumulate = false
)

第三个构造函数:

void cv::calcHist    (   InputArrayOfArrays  images,
const std::vector< int > &    channels,
InputArray  mask,
OutputArray     hist,
const std::vector< int > &    histSize,
const std::vector< float > &  ranges,
bool    accumulate = false
)

【OpenCV4】图像直方图生成函数calcHist()使用详解相关推荐

  1. OpenCV-Python图像直方图计算calcHist函数详解、示例及图形呈现

    ☞ ░ 前往老猿Python博文目录 https://blog.csdn.net/LaoYuanPython ░ 一.引言 在前面几篇直方图相关的文章中介绍了直方图均衡.直方图匹配.局部直方图处理.基 ...

  2. OpenCV-Python直方图计算calcHist函数详解

    ☞ ░ 前往老猿Python博文目录 https://blog.csdn.net/LaoYuanPython ░ 一.引言 在<<数字图像处理>第三章学习总结感悟2:直方图处理: h ...

  3. 【opencv学习笔记】025之直方图计算 - calcHist函数详解

    前言 如果你想了解更多有关于计算机视觉.OpenCV.机器学习.深度学习等相关技术的内容,想与更多大佬一起沟通,那就扫描下方二维码加入我们吧! 1.calcHist函数是干什么滴? 这个问题嘛,看看标 ...

  4. [Python从零到壹] 五十一.图像增强及运算篇之图像灰度直方图对比分析万字详解

    欢迎大家来到"Python从零到壹",在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界.所有文章都将结合案例.代码和作者的经验讲 ...

  5. [Python从零到壹] 六十四.图像识别及经典案例篇之图像傅里叶变换和傅里叶逆变换详解

    祝大家新年快乐,阖家幸福,健康快乐! 欢迎大家来到"Python从零到壹",在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界.所 ...

  6. 使用Python,OpenCV计算图像直方图(cv2.calcHist)

    使用Python,OpenCV计算图像直方图(cv2.calcHist 1. 效果图 2. 原理 2.1 什么是图像直方图? 2.2 计算直方图 2.3 可视化蒙版区域 3. 源码 参考 这篇博客将介 ...

  7. OpenCV之直方图绘制(calcHist函数详解)

    目录 1.直方图的定义 2.calcHist()函数说明 3.绘制直方图 3.1 读取原图像并检查图像是否读取成功 3.2 定义直方图参数并计算直方图 3.3 绘制直方图 4.关于BGR直方图的绘制 ...

  8. matlab机器人工具箱 轨迹生成函数jtraj代码详解

    Matlab中nargin变量是函数输入参数的个数.nargout变量是函数输出的个数 轨迹生成函数jtraj()的代码详解: function [qt,qdt,qddt] = jtraj(q0, q ...

  9. C++ opencv之图像直方图(calcHist)

    这篇博客我们主要来学习图像直方图. 图像直方图是图像像素值的统计学特征.计算代价较小,具有图像平移.旋转.缩放不变性等众多优点,广泛地应用于图像处理的各个领域,特别是灰度图像的阈值分割.基于颜色的图像 ...

最新文章

  1. 信噪比与错误指数matlab,关于信噪比不符合理论值的问题
  2. Scala入门到精通——第二十四节 高级类型 (三)
  3. [html] webSocket怎么做兼容处理?
  4. 雪碧图sprity 合并多图使用心得
  5. XML--可扩展标记语言
  6. 【推荐实践】58招聘推荐排序算法实战与探索
  7. java脚本含义_set -e在bash脚本中的含义是什么?
  8. 表单相关标签之textarea,select
  9. linux telnet 安装
  10. linux 命令find
  11. android driver log,Android调试驱动抓log的方法
  12. FPGA 串口接收不准确,有误码
  13. Php程序监控邮件提醒linux,Linux ping命令实现网络监控 并邮件提醒管理员
  14. k3导入账套_金蝶k3凭证导入导出的操作方法金蝶k3操作指南
  15. gaussian 和gaussview_「测试狗」Gaussian量化模拟入门教程(一)
  16. php时间戳转换成日期格式,PHP时间戳和日期格式相互转换
  17. python人工智能难不难_AI人工智能难不难 怎么进入人工智能行业
  18. leetcode79 word serach 解题报告
  19. 实体与实体之间的联系
  20. 国内外AI绘画软件汇总

热门文章

  1. Python实现动态规划01背包问题
  2. 软考高项 : (21)2016年上半年论文写作真题
  3. 数学公式 svg_世界民族数学:SVG中的毛利人设计
  4. 程序员工作很轻松,一起来看看
  5. Linux kswapd0进程CPU占用过高,病毒清理
  6. java下划线_JAVA找到下划线并且把下划线后面的字母改成大写(简单递归)
  7. 乐蒙网:全球第二大内存和固态硬盘制造商威刚遭勒索攻击
  8. mac 查看redis 版本
  9. 北京大学生物信息学-第五周-新一代测序(NGS) 回帖 BWT算法
  10. mysql查询昨天的日期用DATE_SUB(curdate(), interval 1 day)函数