mat基础教程:

http://blog.csdn.net/sinat_31802439/article/details/50083291

mat 初始化:

Mat M(,,CV_32FC1);
Mat shftMat=(Mat_<double>(,)<<1.0,,leftImg.cols, ,1.0,, ,,1.0);

mat 读取:

topleft2 = presentToLastCorners.col();
topleft2<float>(,);

Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends
on the image from which you are trying to retrieve the data. The table below gives a better insight in this:
- If matrix is of type `CV_8U` then use `Mat.at<uchar>(y,x)`.
- If matrix is of type `CV_8S` then use `Mat.at<schar>(y,x)`.
- If matrix is of type `CV_16U` then use `Mat.at<ushort>(y,x)`.
- If matrix is of type `CV_16S` then use `Mat.at<short>(y,x)`.
- If matrix is of type `CV_32S` then use `Mat.at<int>(y,x)`.
- If matrix is of type `CV_32F` then use `Mat.at<float>(y,x)`.
- If matrix is of type `CV_64F` then use `Mat.at<double>(y,x)`.

在Mat.at中看到

mat 转变数据类型: 转载自http://blog.csdn.net/xiaxiazls/article/details/51204265

cv::Mat matTemp = cv::Mat::zeros(,,CV_32F); //得到一个浮点型的100*100的矩阵
cv::Mat MatTemp2;
matTemp.convertTo(MatTemp2, CV_8U); //把矩阵matTemp转为unsing char类型的矩阵,注在转换过程中有可能数值上会出现一些变化,这个要注意

如何初始化一个任意大小mat

使用构造函数

Mat formedMat(,,CV_8UC3);

图片彩色转黑白

http://blog.csdn.net/qq5132834/article/details/37736693

cvtColor(OpencvimageColor,OpencvimageGray,COLOR_RGB2GRAY);

将两幅图像链接成一幅图片

http://blog.csdn.net/quincuntial/article/details/49947791

计算图片像素平均值和方差

void meanStdDev_test()
{
const char* imagename = "E:/1.jpg";
//产生灰度图
Mat img = imread(imagename);
Mat gray,color;
cvtColor(img, gray, CV_RGB2GRAY);
cout << "Channel: " << gray.channels() << endl; Mat tmp_m, tmp_sd;
double m = , sd = ; m = mean(gray)[];
cout << "Mean: " << m << endl; meanStdDev(gray, tmp_m, tmp_sd);
m = tmp_m.at<double>(,);
sd = tmp_sd.at<double>(,);
cout << "Mean: " << m << " , StdDev: " << sd << endl;
}

Mat type()返回值对应类型:

http://ninghang.blogspot.com/2012/11/list-of-mat-type-in-opencv.html

使用mat出现corrupted unsorted chunks corrupted double-linked list错误,原因在于原来按Mat(col,row) 访问mat,应该是按照Mat(row,col)访问mat才对

逐点访问Mat

http://blog.csdn.net/xiaowei_cqu/article/details/7771760

Mat& ScanImageAndReduceIterator(Mat& I, const uchar* const table)
{
// accept only char type matrices
CV_Assert(I.depth() != sizeof(uchar));
const int channels = I.channels();
switch(channels)
{
case :
{
MatIterator_<uchar> it, end;
for( it = I.begin<uchar>(), end = I.end<uchar>(); it != end; ++it)
*it = table[*it];
break;
}
case :
{
MatIterator_<Vec3b> it, end;
for( it = I.begin<Vec3b>(), end = I.end<Vec3b>(); it != end; ++it)
{
(*it)[] = table[(*it)[]];
(*it)[] = table[(*it)[]];
(*it)[] = table[(*it)[]];
}
}
}
return I;
}


opencv mat的更多相关文章

  1. Matlab to OpenCV Mat

    convert Matlab matrix to OpenCV Mat. Support CV_32FC3 only currently. The Code int matlab2opencv(cv: ...

  2. OpenCV Mat数据类型及位数总结(转载)

    OpenCV Mat数据类型及位数总结(转载) 前言 opencv中很多数据结构为了达到內存使用的最优化,通常都会用它最小上限的空间来分配变量,有的数据结构也会因为图像文件格式的关系而给予适当的变量, ...

  3. OpenCV Mat数据类型指针ptr的使用

    OpenCV Mat数据类型指针ptr的使用 cv::Mat image = cv::Mat(400, 600, CV_8UC1); //宽400,长600 uchar * data00 = imag ...

  4. Qt QImage与OpenCV Mat转换

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/51029382 应一个朋友的要求,整理总 ...

  5. 快速遍历OpenCV Mat图像数据的多种方法和性能分析 | opencv mat for loop

    本文首发于个人博客https://kezunlin.me/post/61d55ab4/,欢迎阅读! opencv mat for loop Series Part 1: compile opencv ...

  6. 海康网络摄像机YV12转换为BGR,由opencv Mat显示 (转)

    我使用的是海康DS-2CD852MF-E, 200万,网络摄像机,已经比较老了,不过SDK在海康官网下载的,开发流程都差不多. 海康摄像机回调解码后的视频数据格式为YV12,顺便说一下YV12的数据格 ...

  7. Live YUV420 和 OpenCV Mat 的互相转换

    1. YUV420 -> Mat 可用于转换接受到的YUV视频源到OpenCV可以识别的数据 Mat myuv( Frame_Height + Frame_Height / 2, Frame_W ...

  8. OpenCv Mat操作总结

    Author:: Maddock Date: 2015-03-23 16:33:49 转载请注明出处:http://blog.csdn.net/adong76/article/details/4053 ...

  9. OpenCV MAT基本图像容器

    参考博客: OpenCv中cv::Mat和IplImage,CvMat之间的转换 Mat - 基本图像容器 Mat类型较CvMat和IplImage有更强的矩阵运算能力,支持常见的矩阵运算(参照Mat ...

  10. Opencv Mat的操作

    cout << mat 有错误的原因 You are using OpenCV built with VS10. The ostream operator << in the ...

随机推荐

  1. Linux arm64内核启动

    原创翻译,转载请注明出处. arm64的异常模型由一组异常级别(EL0-EL3)组成.EL0,EL1有安全模式和非安全模式的区别.EL2是虚拟机管理级别并且只有非安全模式.EL3是最高优先级并且只存在 ...

  2. application/x-www-form-urlencoded从前端到后台

    html <form id="userForm1" enctype="application/x-www-form-urlencoded" method= ...

  3. Python创建目录文件夹

    Python对文件的操作还算是方便的,只需要包含os模块进来,使用相关函数即可实现目录的创建. 主要涉及到三个函数 1.os.path.exists(path) 判断一个目录是否存在 2.os.mak ...

  4. 详细介绍弹性盒模型(display:flex)

    弹性盒模型,即Flexbox,是css3中的新特性,其实弹性盒模型的原身是dispaly:box:这里,我们暂时不考虑旧的,我们只看新的. 为容器指定弹性盒子,只需在父元素(也就是容器)中设置:dis ...

  5. Aspose.words 替换字符 操作

    var path = Server.MapPath("~/doc/demo.doc"); Document doc = new Document(path); DocumentBu ...

  6. Redis学习笔记之基础篇

    Redis是一款开源的日志型key-value数据库,目前主要用作缓存服务器使用. Redis官方并没有提供windows版本的服务器,不过微软官方开发了基于Windows的Redis服务器Micro ...

  7. Hibernate配置文件说明

    <property name="hbm2ddl.auto">create</property> create - 启动Hibernate前先删除表,重新创建 ...

  8. 关于全球唯一标识符GUID

    在C#中的语法: Console.WriteLine(System.Guid.NewGuid()); Console.ReadKey(); System.Guid.NewGuid().ToString ...

  9. (补漏)Springboot2.0 集成shiro权限管理

    原文Springboot2.0 集成shiro权限管理 一.关于停止使用外键. 原本集成shiro建立用户.角色.权限表的时候使用了外键,系统自动创建其中两个关联表,用@JoinTable.看起来省事 ...

  10. Linux总结(二)

      1. 虚拟机安装 a)双系统(不建议初学者一开始去装) b)般建议使用虚拟机来操作试验环境 c)好处:可以模拟真实的环境进行各种的试验和操作 d)在启动之后,在操作的时候会占用一部分的系统资源 1 ...