码迷,mamicode.com
首页 > 其他好文 > 详细

3.1.2固定阈值化

时间:2018-08-13 12:10:35      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:http   1.2   路径   color   https   csdn   最大值   read   sdn   

 

 

 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固定阈值化

标签:http   1.2   路径   color   https   csdn   最大值   read   sdn   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!