opencv mat
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的更多相关文章
- 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数据类型指针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 ...
- 海康网络摄像机YV12转换为BGR,由opencv Mat显示 (转)
我使用的是海康DS-2CD852MF-E, 200万,网络摄像机,已经比较老了,不过SDK在海康官网下载的,开发流程都差不多. 海康摄像机回调解码后的视频数据格式为YV12,顺便说一下YV12的数据格 ...
- Live YUV420 和 OpenCV Mat 的互相转换
1. YUV420 -> Mat 可用于转换接受到的YUV视频源到OpenCV可以识别的数据 Mat myuv( Frame_Height + Frame_Height / 2, Frame_W ...
- OpenCv Mat操作总结
Author:: Maddock Date: 2015-03-23 16:33:49 转载请注明出处:http://blog.csdn.net/adong76/article/details/4053 ...
- OpenCV MAT基本图像容器
参考博客: OpenCv中cv::Mat和IplImage,CvMat之间的转换 Mat - 基本图像容器 Mat类型较CvMat和IplImage有更强的矩阵运算能力,支持常见的矩阵运算(参照Mat ...
- Opencv Mat的操作
cout << mat 有错误的原因 You are using OpenCV built with VS10. The ostream operator << in the ...
随机推荐
- iOS-开发,拨打电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"te ...
- REST接口设计规范
URI格式规范 URI(Uniform Resource Identifiers) 统一资源标示符 URL(Uniform Resource Locator) 统一资源定位符 URI的格式定义如下: ...
- php serialize讲解与json性能测试
[序列化的概念] 序列化是将对象状态转换为可保持或可传输的格式的过程.与序列化相对的是反序列化,它将流转换为对象.这两个过程结合起来,可以轻松地存储和传输数据. 将对象的状态信息转换为可以存储或传输的 ...
- 在fslook
fslook让我们从内核看文件系统而不是从用户态,从这个工具中发现了很多之前忽略过的点. 1)overlay从内核中看到的文件的ino为什么和用户态stat中看到的ino不是一样的?
- Hibernate关联映射之_一对一
数据库模型 一般对一对一的关系而言,会存在一个主从关系.如 人 与 身份证,就是一个一对一关系, 人 是主,身份证 是从 Person PK:id name age Id_Card PK.FK:id ...
- P3375【模板】KMP字符串匹配
前言: 额……很久以前就写了KMP模板(只是半知不解),话说看完了manacher,再回过头看KMP,是真TM简单啊!字符串专题整体较抽象,所以必须牢记思路并时常复习 题目描述 如题,给出两个字符串s ...
- [洛谷P4940]Portal2
题目大意:维护两个栈,几个操作: $PUSH\;x\;num:$把$num$压入栈$x$ $POP\;x:$弹出栈$x$栈顶元素 $ADD\;x:$取出两个栈栈顶,把相加值压入栈$x$ $SUB\;x ...
- [LOJ #2538][PKUWC 2018]Slay the Spire
题目大意:一开始有 $2n$ 张牌,每张牌上都写着一个数字 $w_i$,有两种的牌,每种类型各 $n$ 张: 1.攻击牌:打出后对对方造成牌上的数字的伤害. 2.强化牌:打出后,设数字为 $x$,则其 ...
- wmic的用法
原始文章链接:http://blog.sina.com.cn/s/blog_5fb265c70100w4d0.html 一.wmic的基本命令格式简析 经常看网上的相关资料的话,读者可能会对wmic有 ...
- 【Cf edu 30 B. Balanced Substring】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...