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

边栏推荐
- Minimum cut edge set of undirected graph
- (工作记录)2020年3月11日至2021年3月15日
- 1500萬員工輕松管理,雲原生數據庫GaussDB讓HR辦公更高效
- PG basics -- Logical Structure Management (transaction)
- No Yum source to install SPuG monitoring
- 快过年了,心也懒了
- 【mysql】游标的基本使用
- I've seen many tutorials, but I still can't write a program well. How can I break it?
- C language operators
- 7、数据权限注解
猜你喜欢

Gui Gui programming (XIII) - event handling

Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache

Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)

知识图谱之实体对齐二

use. Net drives the OLED display of Jetson nano

Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices

强化学习-学习笔记5 | AlphaGo

Manifest of SAP ui5 framework json

New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
![[weekly pit] calculate the sum of primes within 100 + [answer] output triangle](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle
随机推荐
【DSP】【第一篇】开始DSP学习
正则表达式收集
Force deduction brush question - 98 Validate binary search tree
Application layer of tcp/ip protocol cluster
Swagger UI教程 API 文档神器
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
性能测试过程和计划
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
Is it safe to open an account in flush? Which securities company is good at opening an account? Low handling charges
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
How to upgrade high value-added links in the textile and clothing industry? APS to help
7、数据权限注解
Common doubts about the introduction of APS by enterprises
"Penalty kick" games
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
[diy] how to make a personalized radio
Rhcsa Road
Mtcnn face detection
recyclerview gridlayout 平分中间空白区域