当前位置:网站首页>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
边栏推荐
- 剖面测量之提取剖面数据
- Knowledge about the memory size occupied by the structure
- Shardingsphere source code analysis
- 2022.7.5-----leetcode.729
- Permission problem: source bash_ profile permission denied
- Classic CTF topic about FTP protocol
- Key structure of ffmpeg - avframe
- MDK debug时设置数据实时更新
- MySQL global lock and table lock
- QT -- thread
猜你喜欢
Determinant learning notes (I)
选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
[online chat] the original wechat applet can also reply to Facebook homepage messages!
电机的简介
OS i/o devices and device controllers
FFMPEG关键结构体——AVCodecContext
Recognize the small experiment of extracting and displaying Mel spectrum (observe the difference between different y_axis and x_axis)
Senparc. Weixin. Sample. MP source code analysis
Doppler effect (Doppler shift)
Problems encountered in the database
随机推荐
FFmpeg抓取RTSP图像进行图像分析
[designmode] Decorator Pattern
About the slmgr command
Gd32f4xx UIP protocol stack migration record
Global and Chinese markets for hinged watertight doors 2022-2028: Research Report on technology, participants, trends, market size and share
An understanding of & array names
What are the functions of Yunna fixed assets management system?
Browser local storage
Yolov5、Pycharm、Anaconda环境安装
Classic CTF topic about FTP protocol
Single merchant v4.4 has the same original intention and strength!
Global and Chinese market of valve institutions 2022-2028: Research Report on technology, participants, trends, market size and share
Go learning --- structure to map[string]interface{}
硬件及接口学习总结
The difference of time zone and the time library of go language
Date类中日期转成指定字符串出现的问题及解决方法
SQLServer连接数据库读取中文乱码问题解决
uniapp开发,打包成H5部署到服务器
MySQL存储引擎
MySQL之函数