当前位置:网站首页>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;
}
边栏推荐
- [asp.net core] set the format of Web API response data -- formatfilter feature
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- Web开发小妙招:巧用ThreadLocal规避层层传值
- Pytest (3) - Test naming rules
- 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
- [DSP] [Part 2] understand c6678 and create project
- What are RDB and AOF
- 2022 portal crane driver registration examination and portal crane driver examination materials
- How to turn a multi digit number into a digital list
- 新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
猜你喜欢
Pytest (3) - Test naming rules
Distributed ID
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle
Core principles of video games
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Kubernetes learning summary (20) -- what is the relationship between kubernetes and microservices and containers?
C language operators
What is the problem with the SQL group by statement
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
随机推荐
PG basics -- Logical Structure Management (transaction)
C language games - three chess
Mtcnn face detection
Use of OLED screen
2110 summary of knowledge points and common problems in redis class
2022 portal crane driver registration examination and portal crane driver examination materials
【DSP】【第一篇】开始DSP学习
Leetcode hot topic Hot 100 day 32: "minimum coverage substring"
Rhcsa Road
##无yum源安装spug监控
Rhcsa Road
New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
Pycharm remote execution
7、数据权限注解
Huawei device command
Simple continuous viewing PTA
OLED屏幕的使用
Regular expression collection
User defined current limiting annotation
Pat 1085 perfect sequence (25 points) perfect sequence