首页 > 其他 > 详细

3.1.2固定阈值化

时间:2018-08-13 11:52:36      阅读:177      评论:0      收藏:0      [点我收藏+]

 

 

 1 ////Source Code:https://blog.csdn.net/gone_huilin/article/details/53222752
 2 #include "opencv2/imgproc/imgproc.hpp"
 3 #include "opencv2/highgui/highgui.hpp"
 4 int main()
 5 {
 6     // 读取源图像及判断
 7     cv::Mat srcImage = cv::imread("D:\\0604.png");//注意路径中冒号是英文!
 8     if (!srcImage.data)
 9         return 1;
10     // 转化为灰度图像
11     cv::Mat srcGray;
12     cv::cvtColor(srcImage, srcGray, CV_RGB2GRAY);
13     cv::imshow("srcGray", srcGray);
14     cv::Mat dstImage;
15     // 初始化阈值参数
16     int thresh = 50;
17     // 初始化阈值化处理的类型 
18     /* 0: 二进制阈值 1: 反二进制阈值 2: 截断阈值
19     3: 0阈值   4: 反0阈值*/
20     int threshType = 0;
21     // 预设最大值
22     const int maxVal = 255;
23     // 固定阈值化操作
24     cv::threshold(srcGray, dstImage, thresh,
25         maxVal, threshType);
26     cv::imshow("dstImage", dstImage);
27     cv::waitKey(0);
28     return 0;
29 }

 

 

技术分享图片

 

3.1.2固定阈值化

原文:https://www.cnblogs.com/thebreakofdawn/p/9466939.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!