当前位置:网站首页>Opencv (1) image reading, display, save, color conversion
Opencv (1) image reading, display, save, color conversion
2022-07-20 09:25:00 【@[email protected]】
Catalog
5. Blocking && Recycling function
0. install
Look at this tutorial
This document is good for reference
2_1_ Introduction to image - OpenCV Official documents in Chinese
1. Read images
Use imread() Function to read image .
The first parameter , Image path .
The second parameter is a flag , It specifies how images are read .
- cv.IMREAD_COLOR: Load color image . The transparency of any image will be ignored . It's the default flag .
- cv.IMREAD_GRAYSCALE: Load image in grayscale mode
- cv.IMREAD_UNCHANGED: Load image , Include alpha passageway
Be careful In addition to these three signs , You can simply pass integers 1、0 or -1.
Warning
Even if the image path is wrong , It doesn't cause any mistakes , But it will give null
// Load image
Mat src = imread("F:/opencv/opencv_tutorial_data-master/images/hist_01.jpg");
// Judge whether the loading is successful
if (src.empty()) {
cout<<"could not load image...\n"<<endl;
return -1;
}
2. Show
// Make windows adaptive
namedWindow("test opencv setup src",WINDOW_FREERATIO);
// Show
imshow("test opencv setup src", src);
3. Color conversion cvtcolor
// Color space conversion cvtcolor
Mat gray;
cvtColor(src, gray, COLOR_RGB2GRAY);
cout << " src.depth " << src.depth() << endl;
cout << " src.channels " << src.channels() << endl;
cout << " gray.depth " << gray.depth() << endl;
cout << " gray.channels " << gray.channels() << endl;
imshow("test opencv setup gray", gray);
4. preservation
// Save image
imwrite("F:/opencv/opencv_tutorial_data-master/images/hist_011.jpg",gray);
5. Blocking && Recycling function
waitKey(0);
destroyAllWindows();
版权声明
本文为[@[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/201/202207190511487287.html
边栏推荐
- Write an Aidl
- Analog image encryption and decryption
- 【论文导读】DAG-GNN: DAG Structure Learning with GNN
- LSTM practice, NLP emotion analysis (kaggle)
- Redis and MySQL double write consistency analysis
- Redis详解(2)基础入门(1)安装与压测
- [deep learning] - model comparison of emotional analysis of IMDB data set (4) - cnn-lstm integrated model
- opencv学习(3)之颜色表操作 逻辑操作 通道分离,合并,混合
- 单片机1-流水灯
- Pytorch迁移学习版的裂缝检测(resnet50)
猜你喜欢
Pytorch实现基本模型
上采样和上卷积的区别
resnet和MobileNet
fast rcnn和faster rcnn
LSTM practice, NLP emotion analysis (kaggle)
YOLOv2详解
inception系列
【论文导读‘‘】Causal Protein-Signaling Networks Derived from Multiparameter Single-Cell Data
[introduction to Thesis] self supervised learning with data augmentationsprovably isolates content from style
RStudio作图
随机推荐
深度学习在组织切片上的应用
Opencv image bit operation
gan01
Write an Aidl
膨胀卷积(空洞卷积)
Mindspore跑model_zoo里的Bert-Thor,outputs 不合理
fast rcnn和faster rcnn
LSTM practice, NLP emotion analysis (kaggle)
transforms_list = [c_vision.Decode(), c_vision.Rescale(1.0 / 127.5, -1.0)]这个是图像标准化【-1,1】是吗?
Redis data type and underlying data structure
Redis and MySQL double write consistency analysis
GhostNet and efficientnet
vs code 安装插件出现XHR error 解决办法
【论文导读】Self-Supervised Learning with Data AugmentationsProvably Isolates Content from Style
Pop up window at the bottom of uniapp applet
Introduction to vLQ
ShuffleNet
Some problems or exceptions encountered in the project and their handling methods
Wechat applet - all pages turn on the sharing circle of friends function at one time (only need to be executed once) (wx.showsharemenu)
解决QT不能發現QT平臺插件