【opencv入门教程】7.读取图像

devtools/2025/2/15 21:54:16/

文章选自:
请添加图片描述

一、imread说明


CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );
功能:读取图像参数:@param filename 导入图像路径.@param flags 图像类型标识位enum ImreadModes {IMREAD_UNCHANGED            = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.IMREAD_GRAYSCALE            = 0,  //!< If set, always convert image to the single channel grayscale image (codec internal conversion).IMREAD_COLOR                = 1,  //!< If set, always convert image to the 3 channel BGR color image.IMREAD_ANYDEPTH             = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.IMREAD_ANYCOLOR             = 4,  //!< If set, the image is read in any possible color format.IMREAD_LOAD_GDAL            = 8,  //!< If set, use the gdal driver for loading the image.IMREAD_REDUCED_GRAYSCALE_2  = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.IMREAD_REDUCED_COLOR_2      = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.IMREAD_REDUCED_GRAYSCALE_4  = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.IMREAD_REDUCED_COLOR_4      = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.IMREAD_REDUCED_GRAYSCALE_8  = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.IMREAD_REDUCED_COLOR_8      = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.IMREAD_IGNORE_ORIENTATION   = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.};

目前支持的图像格式:

  • Windows 位图 - *.bmp, *.dib

  • JPEG 文件 - *.jpeg, *.jpg, *.jpe

  • JPEG 2000 文件 - *.jp2

  • 可移植网络图形 - *.png

  • WebP - *.webp

  • AVIF - *.avif

  • 可移植图像格式 - *.pbm, *.pgm, *.ppm, *.pxm, *.pnm

  • PFM 文件 - *.pfm

  • Sun 光栅 - *.sr, *.ras

  • TIFF 文件 - *.tiff, *.tif

  • OpenEXR 图像文件 - *.exr

  • Radiance HDR - *.hdr, *.pic

  • GDAL 支持的光栅和矢量地理空间数据

二、imreadmulti说明

bool imreadmulti(const String& filename, CV_OUT std::vector<Mat>& mats, int flags = IMREAD_ANYCOLOR);功能:从指定文件加载多通道图像到 Mat对象的向量中参数:@param filename 要加载的文件名。@param mats 一个 Mat 对象的向量,用于存储每一通道。@param flags 可以取 cv::ImreadModes 的值,默认值为 cv::IMREAD_ANYCOLOR。

http://www.ppmy.cn/devtools/140690.html

相关文章

Vue Web开发(二)

1. 项目搭建 1.1. 首页架子搭建 使用Element ui中的Container布局容器&#xff0c;选择倒数第二个样式&#xff0c;将代码复制到Home.vue。 1.1.1.下载less &#xff08;1&#xff09;下载less样式 npm i less   &#xff08;2&#xff09;下载less编辑解析器 npm i less…

12.03 深度学习-池化+卷积扩展+感受野

# ## 3.池化层 # 池化层 (Pooling) 降低维度, 缩减模型大小&#xff0c;提高计算速度. 即: 主要对卷积层学习到的特征图进行下采样&#xff08;SubSampling&#xff09;处理。 # 1. 最大池化 max pooling # 最大池化是从每个局部区域中选择最大值作为池化后的值&#xf…

RabbitMQ核心概念及工作流程 + AMQP

文章目录 一. RabbitMQ核心概念1. Producer, Consumer, Broker2. Connection和Channel3. Virtual host4. Queue5. Exchange 二. RabbitMQ的工作流程三. AMQP四. web界面操作对用户操作对虚拟机操作 一. RabbitMQ核心概念 RabbitMQ是⼀个消息中间件, 也是⼀个⽣产者消费者模型.…

海选女主角

Description 光头强虽然很喜欢教书&#xff0c;但是迫于生活压力&#xff0c;不得不想办法在业余时间挣点外快以养家糊口。 “做什么比较挣钱呢&#xff1f;筛沙子没力气&#xff0c;看大门又不够帅...”光头强老师很是无奈。 “冯小刚比你还难看&#xff0c;现在多有钱呀&a…

uniapp微信小程序任意图片铺满, 超出下滑

uniapp微信小程序任意图片铺满, 超出下滑 直接上代码 <template><scroll-view scroll-y"true" class"rule-box"><img :src"img" mode"widthFix" class"rule-img"></scroll-view> </template&g…

第十六届蓝桥杯模拟赛(第一期)-Python

本次模拟赛我认为涉及到的知识点&#xff1a; 分解质因数 Python的datetime库 位运算 简单dp 1、填空题 【问题描述】 如果一个数 p 是个质数&#xff0c;同时又是整数 a 的约数&#xff0c;则 p 称为 a 的一个质因数。 请问 2024 有多少个质因数。 【答案提交】 这是一道结…

聚簇索引与非聚簇索引

目录 一、聚簇索引&#xff08;Clustered Index&#xff09; 二、非聚簇索引&#xff08;Non-Clustered Index&#xff09; 三、示例说明 一、聚簇索引&#xff08;Clustered Index&#xff09; 定义&#xff1a; 聚簇索引是一种将数据存储和索引合为一体的索引方式。 表中…

TTC模型(1D和2D)理论推导及python实现

目录 第一部分:TTC模型理论背景与应用场景1.1 什么是TTC?1.2 为什么需要TTC?1.3 应用场景第二部分:TTC模型理论推导(1D 和 2D)2.1 1D模型推导距离公式2.2 2D模型推导相对位置与速度第三部分:Python实现:TTC模型计算(面向对象设计)3.1 Python实现的一维TTC代码实现3.2…