当前位置:网站首页>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;
}
边栏推荐
- Math symbols in lists
- SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
- [200 opencv routines] 220 Mosaic the image
- Web开发小妙招:巧用ThreadLocal规避层层传值
- 2022 Guangdong Provincial Safety Officer C certificate third batch (full-time safety production management personnel) simulation examination and Guangdong Provincial Safety Officer C certificate third
- Review questions of anatomy and physiology · VIII blood system
- 【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和
- 全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- Event center parameter transfer, peer component value transfer method, brother component value transfer
- [DSP] [Part 2] understand c6678 and create project
猜你喜欢
C language operators
【DSP】【第二篇】了解C6678和创建工程
Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
【OpenCV 例程200篇】220.对图像进行马赛克处理
Event center parameter transfer, peer component value transfer method, brother component value transfer
OLED屏幕的使用
【mysql】触发器
【DSP】【第一篇】开始DSP学习
随机推荐
I've seen many tutorials, but I still can't write a program well. How can I break it?
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle
Xcode6 error: "no matching provisioning profiles found for application"
Huawei device command
逻辑是个好东西
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
1_ Introduction to go language
解剖生理学复习题·VIII血液系统
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
[DIY]自己设计微软MakeCode街机,官方开源软硬件
Utilisation de l'écran OLED
数据湖(八):Iceberg数据存储格式
C language operators
How does kubernetes support stateful applications through statefulset? (07)
Review questions of anatomy and physiology · VIII blood system
What are RDB and AOF
快过年了,心也懒了
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
7. Data permission annotation