Mat Mat::rowRange(int startrow, int endrow)
取出矩阵 [startrow, endrow) 行 ,如rowRange(0, 2)意识是取出第0行和第1行
colRange(0, 2)意思是取出矩阵的第0列和第1列,然后重组成一个新的矩阵返回
#include "pch.h"
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat Test = (Mat_<double>(3, 3) << 0, 1, 2, 3, 4, 5, 6, 7, 8);
cout << "Total matrix:" << endl;
cout << Test << endl;
Mat testrow = Test.rowRange(0, 2).clone();
cout << "Row range:" << endl;
cout << testrow << endl;
cout << "Test 1 row:" << endl;
cout << Test.row(0) << endl;
Mat testcol = Test.colRange(0, 2).clone();
cout << "Col range:" << endl;
cout << testcol << endl;
waitKey(0);
return 0;
}
FR:徐海涛(hunk Xu)