opencv Mat基础
Mat
Mat由两部分构成
- matrix header
- pointer to the matrix containing the pixel values
Mat is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude.
Mat A, C; // creates just the header parts
A = imread(argv[1], IMREAD_COLOR); // here we'll know the method used (allocate matrix)
Mat B(A); // Use the copy constructor
C = A; // Assignment operator
A,B,C的matrix header不同,但是pointer是一样的.指向同样的内存.修改一个会影响另一个.
Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
Mat E = A(Range::all(), Range(1,3)); // using row and column boundaries
可以通过如上代码方式使得matrix header指向全部数据的一个子集.
Mat F = A.clone();
Mat G;
A.copyTo(G);
opencv提供了深拷贝的方法 cv::Mat::clone() and cv::Mat::copyTo() ,会将数据部分也拷贝.
存储方式
opencv默认的是bgr的顺序.
颜色空间有好多种
- RGB is the most common as our eyes use something similar, however keep in mind that OpenCV standard display system composes colors using the BGR color space (a switch of the red and blue channel).
- The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image.
- YCrCb is used by the popular JPEG image format.
- CIE Lab* is a perceptually uniform color space, which comes handy if you need to measure the distance of a given color to another color.
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
CV_[The number of bits per item][Signed or Unsigned][Type Prefix]C[The channel number]
比如CV_8UC3代表每个像素值是一个8bit的unsigned char代表(表达范围0-255),有3个通道.
opencv Mat基础的更多相关文章
- 【VS开发】C++ opencv Mat基础
OpenCV2:Mat 1.Mat基础 在计算机内存中,数字图像是已矩阵的形式保存的.OpenCV2中,数据结构Mat是保存图像像素信息的矩阵,它主要包含两部分:矩阵头和一个指向像素数据的矩阵指针. ...
- Matlab to OpenCV Mat
convert Matlab matrix to OpenCV Mat. Support CV_32FC3 only currently. The Code int matlab2opencv(cv: ...
- OpenCV Mat数据类型及位数总结(转载)
OpenCV Mat数据类型及位数总结(转载) 前言 opencv中很多数据结构为了达到內存使用的最优化,通常都会用它最小上限的空间来分配变量,有的数据结构也会因为图像文件格式的关系而给予适当的变量, ...
- opencv mat
mat基础教程: http://blog.csdn.net/sinat_31802439/article/details/50083291 mat 初始化: Mat M(,,CV_32FC1); Ma ...
- OpenCV Mat数据类型指针ptr的使用
OpenCV Mat数据类型指针ptr的使用 cv::Mat image = cv::Mat(400, 600, CV_8UC1); //宽400,长600 uchar * data00 = imag ...
- Qt QImage与OpenCV Mat转换
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/51029382 应一个朋友的要求,整理总 ...
- 快速遍历OpenCV Mat图像数据的多种方法和性能分析 | opencv mat for loop
本文首发于个人博客https://kezunlin.me/post/61d55ab4/,欢迎阅读! opencv mat for loop Series Part 1: compile opencv ...
- 【Opencv】Mat基础
1.Mat::imread() C++: Mat imread(const string& filename, int flags=1 ) filename – Name of file to ...
- 【转】OpenCV Mat数据结构
转载自xiahouzuoxin原文 OpenCV基础篇之Mat数据结构 程序及分析 /* * FileName : MatObj.cpp * Author : xiahouzuoxin @163.co ...
- opencv Mat 像素操作
1 cv::Mat cv::Mat是一个n维矩阵类,声明在<opencv2/core/core.hpp>中. class CV_EXPORTS Mat { public: //a lo ...
随机推荐
- ceph安装笔记
配置源 ceph版本为luminous [root@ceph-node1 ~]# yum install -y https://dl.fedoraproject.org/pub/epel/epel-r ...
- 给OPi Zero Plus添加USB启动功能
为使OPi Zero Plus支持U盘启动,需要在板载的SPI Flash当中刷入uboot.在这个过程当中绕了很多弯路,特此记录 最终操作步骤见文末 网上的教程仅使用sudo modprobe sp ...
- C#关于MySQL中文乱码问题
本人在写一个测试demo的时候,遇到一个问题就是添加的中文数据在数据库定义的明明是varchar类型,但是显示出来还是乱码,不过还是自己粗心导致的问题. 以下三种方式可以自查一下: 1. 首先检查 ...
- 发布一个简单的npm包
本文简单地记录了发布一个简单npm包的过程,以便后续参考使用. 初始化npm init 通过npm init创建一个package.json文件 D:\robin\lib\weapp-utils> ...
- Web前端基础(18):jQuery基础(五)
1. 事件 前面我们介绍完js的事件流的概念之后,相信大家对事件流也有所了解了.那么接下来我们看一下jquery的事件操作. 在说jquery的每个事件之前,我们先来看一下事件对象 . 1.1 事件对 ...
- Python中经典排序方法
数据的排序是在解决实际问题时经常用到的步骤,也是数据结构的考点之一,下面介绍10种经典的排序方法. 首先,排序方法可以大体分为插入排序.选择排序.交换排序.归并排序和桶排序四大类,其中,插入排序又分为 ...
- SpringCloud(一):了解SpringCloud
一.SpringCloud 简介 首先看看SpringCloud官方的介绍: Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由, ...
- choose Perseverance :)
心里话 很久都没有更新博客了,我会陆陆续续的把云笔记中的一些有意思的文章放在博客中. 这10个月以来经历了很多,9月份参加了省赛获得了一个二等奖,和一等奖失之交臂的滋味很难受,到10月份开始维护自己的 ...
- [转]UIPATH机器人指南
本文转自:https://blog.csdn.net/weixin_33957036/article/details/80907372 介绍 机器人是UiPath的执行代理,可运行Studio中内置的 ...
- PHP代码篇(六)--如何根据邀请人id查询满足条件的会员上级
说,如果有一个会员表,每一个会员都有一个邀请人from_id字段(记录该会员是谁邀请的),知道一个会员id,现在需要查询某一个会员是否是该会员的下级. 表如下: 一.当下需求 1.我们需要知道会员id ...