当前位置:网站首页>《opencv学习笔记》-- 图像的载入和保存
《opencv学习笔记》-- 图像的载入和保存
2022-06-24 10:00:00 【cc_rong】
目录
图像载入:imread()函数
Mat imread(const string& filename, int flags = IMREAD_COLOR )参数一:图像的名称
参数二:读取标记,用于选择读取图片的方式,默认值为IMREAD_COLOR,flag值的设定与用什么颜色格式读取图片有关。
IMREAD_COLOR: 总是读取三通道图像
IMREAD_GRAYSCALE: 总是读取单通道
IMREAD_ANYCOLOR: 通道数由文件实际通道数(不超过3)
IMREAD_ANYDEPTH: 允许加载超过8bit深度
IMREAD_UNCHANGED: (读取图像时,保留图像中的alpha通道)
支持图像格式类型;
图像保存:imwrite()函数
bool imwrite(const string& filename,
InputArray image,
const vector<int>& params = vector<int>())参数一:保存给定的文件名,扩展名:
jpg或者jpeg、jp2、tif或tiff、png(推荐使用)、bmp、ppm、pgm
参数二:存储的输入图像。
参数三:特殊类型文件的写入操作时所需的数据
代码
// 读取图像 Mat image = imread("1.jpg"); // 判断是否读取成功 if(image.data == NULL) { return ; } // 显示 imshow("readImg", image); // 保存图像 if(!imwrite("1To2.jpg", image)) { return ; }
边栏推荐
- Today in history: Turing's birth day; The birth of the founder of the Internet; Reddit goes online
- Cloud vendor secondary virtualization restrictions
- Programmers spend most of their time not writing code, but...
- 【206】使用php语言去生成go语言的代码
- Nxshell session management supports import and export
- [Qianfan 618 countdown!] IAAs operation and maintenance special preferential activities
- Istio best practice: graceful termination
- System design: load balancing
- Code is really - omnipotent! Refuse to fight
- What is the bin file for? How to open the file correctly
猜你喜欢

Fashionable pop-up mode login registration window

服乔布斯不服库克,苹果传奇设计团队解散内幕曝光

SQL Server about like operator (including the problem of field data automatically filling in spaces)

Rising bubble canvas breaking animation JS special effect

Maui的学习之路 -- 开篇

@Requestbody annotation

【本周六活动】.NET Day in China

"Write once, run at all ends", Qualcomm released AI software stack!

Déplacer Tencent sur le cloud a guéri leur anxiété technologique

PHP SMS notification + voice broadcast automatic double call
随机推荐
Why use a firewall? What is the function of firewall?
软件测试 对前一日函数的基本路径测试
Shell脚本(.sh文件)如何执行完毕之后不自动关闭、闪退?
What is wireless WiFi? What are the benefits of wireless WiFi
Go basic series | 4 Environment construction (Supplement) - gomod doubts
Shape change loader loads jsjs special effect code
Anonymous Messenger: hidden communication of Trojan horse
Programmers spend most of their time not writing code, but...
Multi gate mixture of experts and code implementation
The latest entry date of SQL Sever test questions
【毕业季·进击的技术er】绕树三匝,何枝可依?
Qt: judge whether the string is in numeric format
Group policy export import
Istio best practice: graceful termination
[深度学习][pytorch][原创]crnn在高版本pytorch上训练loss为nan解决办法
How to use data analysis tools to deal with emergencies in retail industry
【206】使用php语言去生成go语言的代码
Mongodb index operation
Influence of DEX optimization on arouter lookup path
Simple pricelist style code
