当前位置:网站首页>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
边栏推荐
- Global and Chinese markets for pressure and temperature sensors 2022-2028: Research Report on technology, participants, trends, market size and share
- Solve the problem of reading Chinese garbled code in sqlserver connection database
- Doppler effect (Doppler shift)
- LeetCode 斐波那契序列
- 多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
- 常用API类及异常体系
- OpenCV经典100题
- Intranet Security Learning (V) -- domain horizontal: SPN & RDP & Cobalt strike
- Date类中日期转成指定字符串出现的问题及解决方法
- FFmpeg抓取RTSP图像进行图像分析
猜你喜欢
FPGA内部硬件结构与代码的关系
亲测可用fiddler手机抓包配置代理后没有网络
Classic CTF topic about FTP protocol
How to solve the problems caused by the import process of ecology9.0
Priority queue (heap)
数据库遇到的问题
【NOI模拟赛】Anaid 的树(莫比乌斯反演,指数型生成函数,埃氏筛,虚树)
【DesignMode】组合模式(composite mode)
anconda下载+添加清华+tensorflow 安装+No module named ‘tensorflow‘+KernelRestarter: restart failed,内核重启失败
Key structure of ffmpeg - avformatcontext
随机推荐
Problems encountered in the database
7.5 simulation summary
Codeforces gr19 D (think more about why the first-hand value range is 100, JLS yyds)
Upgrade openssl-1.1.1p for openssl-1.0.2k
LeetCode 斐波那契序列
Go learning --- structure to map[string]interface{}
The difference of time zone and the time library of go language
关于slmgr命令的那些事
多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)
Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
DEJA_VU3D - Cesium功能集 之 055-国内外各厂商地图服务地址汇总说明
[designmode] adapter pattern
【在线聊天】原来微信小程序也能回复Facebook主页消息!
第16章 OAuth2AuthorizationRequestRedirectWebFilter源码解析
时间戳的拓展及应用实例
MySql——CRUD
Yolov5、Pycharm、Anaconda环境安装
【NOI模拟赛】Anaid 的树(莫比乌斯反演,指数型生成函数,埃氏筛,虚树)
《编程之美》读书笔记