当前位置:网站首页>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;
}

边栏推荐
- 【每周一坑】信息加密 +【解答】正整数分解质因数
- Detailed explanation of knowledge map construction process steps
- Spiral square PTA
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
- c#使用oracle存储过程获取结果集实例
- Minimum cut edge set of undirected graph
- 新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- 知识图谱之实体对齐二
- Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
- #yyds干货盘点#重新梳理箭头函数的this
猜你喜欢

逻辑是个好东西

Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an

防火墙基础之外网服务器区部署和双机热备

No Yum source to install SPuG monitoring

The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix

Utilisation de l'écran OLED

硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件

知识图谱构建流程步骤详解

Comment faire une radio personnalisée

【微信小程序】运行机制和更新机制
随机推荐
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
电子游戏的核心原理
Why do novices often fail to answer questions in the programming community, and even get ridiculed?
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
Value of APS application in food industry
Gui Gui programming (XIII) - event handling
知识图谱之实体对齐二
In line elements are transformed into block level elements, and display transformation and implicit transformation
Core principles of video games
Detailed explanation of knowledge map construction process steps
Infrared thermometer based on STM32 single chip microcomputer (with face detection)
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
【微信小程序】運行機制和更新機制
Performance test process and plan
Huawei device command
Minimum cut edge set of undirected graph
Recyclerview GridLayout bisects the middle blank area
Dynamically switch data sources
C language games - minesweeping