一 . Mat类总结Point类总结

一. Mat类

1. 代码示例

#include <iostream>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{
  Mat image = imread("/home/chang/projects/opencv_GPU_example/test.jpg");
 
  cout << "image.data = "      << image.data        << endl;  // .data表示指向Ma矩阵的首地址
  cout << "image.dims = "      << image.dims        << endl;  // 矩阵的维度,二位矩阵dims=2,三维矩阵dims=3????????
  cout << "image.size = "      << image.size        << endl;  // 行×列(y*x)
  cout << "image.size() = "    << image.size()      << endl;  // 列×行(x*y)
  cout << "image.rows = "      << image.rows        << endl;  // 行
  cout << "image.cols = "      << image.cols        << endl;  // 列
  cout << "image.channels = "  << image.channels()  << endl;  // 图像的通道数,彩色图像为3通道
  cout << "image.depth() = "   << image.depth()     << endl;  // depth用来度量每个像素中每个通道的精度  //enum{CV_8U=0,CV_8S=1,CV_16U=2,CV_16S=3,CV_32S=4,CV_32F=5,CV_64F=6}
  cout << "image.step = "      << image.step        << endl;  // ???????
  cout << "image.step(1) = "   << image.step1()     << endl;  // ???????
  cout << "image.elemsize = "  << image.elemSize()  << endl;  // 一个像素点的大小, elemSize()=8bit的倍数*通道数
  cout << "image.elemsize1 = " << image.elemSize1() << endl;  // 单个通道的数据大小 =(elemSize / Channel)
  cout << "image.type = "      << image.type()      << endl;  // Mat矩阵的类型,包含有矩阵中元素的类型以及通道数信息
 
  namedWindow("car");
  imshow("car", image);
  waitKey(0);
  return 0;
}

2. 常用矩阵类型总结:C(k)表示有k个通道

基本类型C1(或留空)C2C3C(n)
CV_8U08168(n-1)
CV_8S19178(n-1)+1
CV_16U210188(n-1)+2
CV_16S311198(n-1)+3
CV_32S412208(n-1)+4
CV_32F513218(n-1)+5
CV_64F614228(n-1)+6

 

二. Point类

  typedef Point_<int> Point2i;
  typedef Point2i Point;
  typedef Point_<float> Point2f;
  typedef Point_<double> Point2d;
  typedef Point3_<int> Point3i;
  typedef Point3_<float> Point3f;
  typedef Point3_<double> Point3d;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值