当前位置:网站首页>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
边栏推荐
- 时区的区别及go语言的time库
- 软件测试工程师必会的银行存款业务,你了解多少?
- GD32F4xx uIP协议栈移植记录
- Room cannot create an SQLite connection to verify the queries
- Mysql - CRUD
- N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2
- Key structure of ffmpeg -- AVCodecContext
- JS can really prohibit constant modification this time!
- 【DesignMode】装饰者模式(Decorator pattern)
- Choose to pay tribute to the spirit behind continuous struggle -- Dialogue will values [Issue 4]
猜你喜欢

如何解决ecology9.0执行导入流程流程产生的问题

关于slmgr命令的那些事

剖面测量之提取剖面数据

Recognize the small experiment of extracting and displaying Mel spectrum (observe the difference between different y_axis and x_axis)

Ffmpeg learning - core module

Hudi of data Lake (2): Hudi compilation

Key structure of ffmpeg - avformatcontext

How much do you know about the bank deposit business that software test engineers must know?

Miaochai Weekly - 8

权限问题:source .bash_profile permission denied
随机推荐
OpenCV经典100题
How much do you know about the bank deposit business that software test engineers must know?
认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
What is information security? What is included? What is the difference with network security?
选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
An understanding of & array names
Classical concurrency problem: the dining problem of philosophers
OS i/o devices and device controllers
Intranet Security Learning (V) -- domain horizontal: SPN & RDP & Cobalt strike
Configuring OSPF GR features for Huawei devices
7.5模拟赛总结
Search (DFS and BFS)
Go learning - dependency injection
Global and Chinese markets of POM plastic gears 2022-2028: Research Report on technology, participants, trends, market size and share
STM32 configuration after chip replacement and possible errors
Room cannot create an SQLite connection to verify the queries
【DesignMode】组合模式(composite mode)
JS 这次真的可以禁止常量修改了!
数据分析思维分析方法和业务知识——分析方法(二)
【DesignMode】适配器模式(adapter pattern)