当前位置:网站首页>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
边栏推荐
- anconda下载+添加清华+tensorflow 安装+No module named ‘tensorflow‘+KernelRestarter: restart failed,内核重启失败
- Yunna | what are the main operating processes of the fixed assets management system
- 多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
- NSSA area where OSPF is configured for Huawei equipment
- FFMPEG关键结构体——AVCodecContext
- 数据库遇到的问题
- Go learning --- read INI file
- PHP determines whether an array contains the value of another array
- OS i/o devices and device controllers
- notepad++正则表达式替换字符串
猜你喜欢
Atcoder beginer contest 258 [competition record]
MySql——CRUD
Upgrade openssl-1.1.1p for openssl-1.0.2k
AtCoder Beginner Contest 258【比赛记录】
[online chat] the original wechat applet can also reply to Facebook homepage messages!
FFT learning notes (I think it is detailed)
[designmode] composite mode
NSSA area where OSPF is configured for Huawei equipment
数据库遇到的问题
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
随机推荐
MySQL functions
7.5 decorator
多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
Start from the bottom structure and learn the introduction of fpga---fifo IP core and its key parameters
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
Go learning - dependency injection
Key structure of ffmpeg -- AVCodecContext
云呐|固定资产管理系统功能包括哪些?
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
Configuring OSPF GR features for Huawei devices
Gd32f4xx UIP protocol stack migration record
An understanding of & array names
关于结构体所占内存大小知识
数据分析思维分析方法和业务知识——分析方法(三)
Search (DFS and BFS)
MDK debug时设置数据实时更新
从底层结构开始学习FPGA----FIFO IP核及其关键参数介绍
Tools to improve work efficiency: the idea of SQL batch generation tools
QT -- thread