当前位置:网站首页>Opencv learning log 12 binarization of Otsu method

Opencv learning log 12 binarization of Otsu method

2022-07-06 15:42:00 @Spring sauce

Preface

This article focuses on opencv How to use Otsu method to binarize images in .

One 、 Binarization of Otsu method

// Third question   Binarization of Otsu method 
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;

int main()
{
    
	cv::Mat srcMat = imread("C://Users//john//Desktop//1.jpg", 0);
	cv::Mat resMat;
// imshow("src", srcMat);
// threshold(srcMat, resMat, 100, 255, THRESH_OTSU); // Dajin law 
	threshold(srcMat, resMat, 100, 255, THRESH_BINARY); // Fixed threshold 
// adaptiveThreshold(srcMat, resMat, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 15, 10); // The adaptive 
	imshow("res", resMat);
	waitKey(0);
}

summary

1. The code can run directly , If you don't understand, please leave a message .

原网站

版权声明
本文为[@Spring sauce]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131317245176.html