当前位置:网站首页>Opencv learning example code 3.2.3 image binarization
Opencv learning example code 3.2.3 image binarization
2022-07-06 20:53:00 【Terror blade】
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <iomanip>
#include <opencv2/opencv.hpp>
#include <vector>
#include <opencv2/imgproc/types_c.h>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
cout<<"1234"<<endl;
Mat img=imread("lena.png");
if(img.empty())
{
cout<<"open error"<<endl;
return -1;
}
Mat gray;
cvtColor(img,gray,COLOR_BGR2GRAY);
Mat img_B ,img_B_V,gray_B,gray_B_V,gray_T,gray_T_V,gray_TRUNC;
threshold(img,img_B,125,255,THRESH_BINARY);
threshold(img,img_B_V,125,255,THRESH_BINARY_INV);
imshow("img_B",img_B);
imshow("img_B_V",img_B_V);
threshold(gray,gray_B,125,255,THRESH_BINARY);
threshold(gray,gray_B_V,125,255,THRESH_BINARY_INV);
imshow("gray_B",gray_B);
imshow("gray_B_V",gray_B_V);
threshold(gray,gray_T,125,255,THRESH_TOZERO);
threshold(gray,gray_T_V,125,255,THRESH_TOZERO_INV);
imshow("gray_T",gray_T);
imshow("gray_T_V",gray_T_V);
threshold(gray,gray_TRUNC,125,255,THRESH_TRUNC);
imshow("gray_TRUNC",gray_TRUNC);
Mat img_Thr=imread("threshold.png",IMREAD_GRAYSCALE);
Mat img_Thr_O,img_Thr_T;
threshold(img_Thr,img_Thr_O,100,255,THRESH_BINARY|THRESH_OTSU);
threshold(img_Thr,img_Thr_T,100,255,THRESH_BINARY|THRESH_TRIANGLE);
imshow("img_Thr_O",img_Thr_O);
imshow("img_Thr_T",img_Thr_T);
Mat adaptive_mean,adaptive_gauss;
adaptiveThreshold(img_Thr,adaptive_mean,255,ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,55,0);
adaptiveThreshold(img_Thr,adaptive_gauss,255,ADAPTIVE_THRESH_GAUSSIAN_C,THRESH_BINARY,55,0);
imshow("adaptive_mean",adaptive_mean);
imshow("adaptive_gauss",adaptive_gauss);
waitKey(0);
return 0;
}

边栏推荐
- Force deduction brush question - 98 Validate binary search tree
- 快过年了,心也懒了
- Comment faire une radio personnalisée
- Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
- OLED屏幕的使用
- Kubernetes learning summary (20) -- what is the relationship between kubernetes and microservices and containers?
- Simple continuous viewing PTA
- New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
- Why do novices often fail to answer questions in the programming community, and even get ridiculed?
- 【微信小程序】运行机制和更新机制
猜你喜欢

Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)

“罚点球”小游戏
![[DIY]如何制作一款个性的收音机](/img/fc/a371322258131d1dc617ce18490baf.jpg)
[DIY]如何制作一款个性的收音机

面试官:Redis中有序集合的内部实现方式是什么?

OLED屏幕的使用

使用.Net分析.Net达人挑战赛参与情况

1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效

OAI 5g nr+usrp b210 installation and construction

15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient

Utilisation de l'écran OLED
随机推荐
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
Pytest (3) - Test naming rules
#yyds干货盘点#重新梳理箭头函数的this
Performance test process and plan
Application layer of tcp/ip protocol cluster
[weekly pit] output triangle
Value of APS application in food industry
2110 summary of knowledge points and common problems in redis class
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
Why do novices often fail to answer questions in the programming community, and even get ridiculed?
知识图谱构建流程步骤详解
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Spiral square PTA
Summary of different configurations of PHP Xdebug 3 and xdebug2
【DSP】【第二篇】了解C6678和创建工程
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
Manifest of SAP ui5 framework json
OSPF多区域配置
Web开发小妙招:巧用ThreadLocal规避层层传值
What is the problem with the SQL group by statement