当前位置:网站首页>Opencv classic 100 questions
Opencv classic 100 questions
2022-07-06 00:21:00 【It rained and windy last night】
Catalog

Preface
Common knowledge records
1. CV_8UC1,CV_8UC2,CV_8UC3 Wait
The general image file format uses Unsigned 8bits Well ,CvMat The parameter type corresponding to the matrix is
CV_8UC1,CV_8UC2,CV_8UC3.
( final 1、2、3 Indicates the number of channels , for example RGB3 The channel is used CV_8UC3)
and float yes 32 Bit , Corresponding CvMat Data structure parameters are :CV_32FC1,CV_32FC2,CV_32FC3…
double yes 64bits, Corresponding CvMat Data structure parameters :CV_64FC1,CV_64FC2,CV_64FC3 etc. .
One 、 Channel switching
subject : cv2::imread() The coefficient of is BGR In the order of .code
// Read images , And then BGR Replace channel with RGB passageway .
//Mat The image has no length or width , Only width and height , This should be understandable width = cols height = rows
void MainWindow::test1ChannelSwap()
{
Mat sourceImage = imread("../Image/imori.jpg");
qDebug()<<"--->z MainWindow::test1ChannelSwap()1"<<sourceImage.rows<<sourceImage.cols;
imshow("sourceImage",sourceImage);
int width = sourceImage.cols;
int height = sourceImage.rows;
Mat newImage = Mat::zeros(height,width,CV_8UC3);
for (int i = 0; i < width; i++)
{
for (int j = 0; j<height; j++)
{
newImage.at<cv::Vec3b>(i, j)[0] = sourceImage.at<cv::Vec3b>(i, j)[2];
newImage.at<cv::Vec3b>(i, j)[1] = sourceImage.at<cv::Vec3b>(i, j)[1];
newImage.at<cv::Vec3b>(i, j)[2] = sourceImage.at<cv::Vec3b>(i, j)[0];
}
}
imshow("newImage",newImage);
}
Two 、 Graying
subject : Gray scale is a kind of expression method of image brightness , Calculate by the following formula : Y = 0.2126 R + 0.7152 G + 0.0722 B Y = 0.2126\ R + 0.7152\ G + 0.0722\ B Y=0.2126 R+0.7152 G+0.0722 Bcode
void MainWindow::test2Grayscale()
{
Mat sourceImage = imread("../Image/imori.jpg");
qDebug()<<"--->z MainWindow::test1ChannelSwap()1"<<sourceImage.rows<<sourceImage.cols;
imshow("sourceImage",sourceImage);
int width = sourceImage.cols;
int height = sourceImage.rows;
Mat newImage = Mat::zeros(height,width,CV_8UC1);// Be careful , It's OK to use a channel when applying , Because it's just a grayscale image .
for (int i = 0; i<height; i++)
{
for (int j = 0; j < width; j++)
{
newImage.at<uchar>(i,j) = 0.0126 * (float)sourceImage.at<Vec3b>(i,j)[2]+ 0.7152 * (float)sourceImage.at<Vec3b>(i,j)[1] + 0.0722 * (float)sourceImage.at<Vec3b>(i,j)[0];
}
}
imshow("newImage",newImage);
}
Text
Reference resources
边栏推荐
- Permission problem: source bash_ profile permission denied
- MySql——CRUD
- Global and Chinese market of digital serial inverter 2022-2028: Research Report on technology, participants, trends, market size and share
- 时间戳的拓展及应用实例
- LeetCode 1189. Maximum number of "balloons"
- Room cannot create an SQLite connection to verify the queries
- [noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)
- N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2
- PHP determines whether an array contains the value of another array
- XML配置文件
猜你喜欢
关于结构体所占内存大小知识
FFT 学习笔记(自认为详细)
uniapp开发,打包成H5部署到服务器
FFmpeg学习——核心模块
LeetCode 1598. Folder operation log collector
18. (ArcGIS API for JS) ArcGIS API for JS point collection (sketchviewmodel)
Intranet Security Learning (V) -- domain horizontal: SPN & RDP & Cobalt strike
[designmode] Decorator Pattern
Ffmpeg learning - core module
电机的简介
随机推荐
Calculate sha256 value of data or file based on crypto++
[Chongqing Guangdong education] Chongqing Engineering Vocational and Technical College
LeetCode 6005. The minimum operand to make an array an alternating array
Key structure of ffmpeg - avformatcontext
Pointer pointer array, array pointer
N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2
Yunna | what are the main operating processes of the fixed assets management system
如何利用Flutter框架开发运行小程序
[binary search tree] add, delete, modify and query function code implementation
State mode design procedure: Heroes in the game can rest, defend, attack normally and attack skills according to different physical strength values.
Tools to improve work efficiency: the idea of SQL batch generation tools
7.5 装饰器
Classic CTF topic about FTP protocol
Date类中日期转成指定字符串出现的问题及解决方法
Go learning --- read INI file
FFT 学习笔记(自认为详细)
What is information security? What is included? What is the difference with network security?
Codeforces Round #804 (Div. 2)【比赛记录】
第16章 OAuth2AuthorizationRequestRedirectWebFilter源码解析
MySQL之函数