zoukankan      html  css  js  c++  java
  • 3.1.2固定阈值化

     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 }

  • 相关阅读:
    菜鸟的it之路-起航
    实验报告四
    实验报告三
    实验报告二
    实验报告一
    远程连接
    操作系统安装
    服务器硬件组成
    linux系统下排查cpu过高原因
    windows系统下排查Java项目cpu过高原因
  • 原文地址:https://www.cnblogs.com/thebreakofdawn/p/9466939.html
Copyright © 2011-2022 走看看