opencvinRange()二值化函数

将在两个阈值内的像素值设置为白色(255),而不在阈值区间内的像素值设置为黑色(0)

#include<opencv2/opencv.hpp>
#include<iostream>
#include  <vector>


int main(int argc, char** argv) {

    cv::Mat M = (cv::Mat_<double>(3, 3) << 0, 10, 160, 11, 250, 240, 230, 188, 199);
    std::cerr << M << std::endl << std::endl;

    cv::Mat dst;
    cv::inRange(M, cv::Scalar(100), cv::Scalar(200), dst);
    /*
    参数1:输入要处理的图像,可以为单通道或多通道
    参数2:包含下边界的数组或标量
    参数3:包含上边界数组或标量
    参数4:输出图像,与输入图像src 尺寸相同且为CV_8U 类型
    */
    std::cerr << dst << std::endl << std::endl;


    cv::waitKey(0);
    return 0;
}

  

原文地址:https://www.cnblogs.com/liming19680104/p/15796196.html