学习OpenCV(六)

来源:互联网 发布:水牛 黄牛 知乎 编辑:程序博客网 时间:2024/06/06 19:01

续学习OpenCV(五)

使用OpenCV有关直方图的几个函数(二):

函数一:

cv::threshold(srcImage, desImage, threshold, malVal, cv::THRESH_BINARY);

在最后一个参数为cv::THERSH_BINARY时本函数实现把源图像转换成二值图像,门限值为threshold,最大值为malVal

函数二:

cv::calcBackProject(&image,

1,            // we only use one image at a time

channels,     // vector specifying what histogram dimensions    

                           //belong to what image channels                                         

histogram,   // the histogram we are using

result,       // the resulting back projection image

ranges,       // the range of values, for each dimension

255.0         // the scaling factor is chosen such that a histogram

                           //value of 1 maps to 255

  );

函数在图像中寻找指定的对象

 histogram是规范化直方图

255.0是缩放因子

函数三:

直方图规范化

cv::normalize(histogram,Mat,1.0)

cv::normalize(shistogram,sparseMat,1.0,cv::NORM_L2);

直方图规范化会把直方图每一个值规范到(0.0 , 1.0)






0 0
原创粉丝点击