关于rowRange()和colRange()函数,很多都是转载一个3x3矩阵的例子来说事,让初学者云里雾里,有的甚至用行列扫描的方式输出显示,更增加了云里雾里~-~
运行结果:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
cout << "OpenCV rowRang() Test!" << endl << endl;
//定义病初始化5x5矩阵
Mat Martrix55 = (Mat_<int>(5, 5) << 1,2,3,4,5,
11,12,13,14,15,
21,22,23,24,25,
31,32,33,34,35,
41,42,43,44,45);
cout << "Martrix55 = " << endl << Martrix55 << endl << endl;
Mat mchunk1 = Martrix55.rowRange(0,1);
cout << "mchunk1 = Martrix55.rowRange(0,1)" << endl << "mchunk1 = " << endl << mchunk1 << endl << endl;
Mat mchunk2 = Martrix55.rowRange(0, 2);
cout << "mchunk2 = Martrix55.rowRange(0, 2)" << endl << "mchunk2 = " << endl << mchunk2 << endl << endl;
Mat mchunk3 = Martrix55.rowRange(0, 3);
cout << "mchunk3 = Martrix55.rowRange(0, 3)" << endl << "mchunk3 = " << endl << mchunk3 << endl << endl;
Mat mchunk4 = Martrix55.rowRange(3, 5);
cout << "mchunk4 = Martrix55.rowRange(3, 5)" << endl << "mchunk4 = " << endl << mchunk4 << endl << endl;
Mat mchunk5 = Martrix55.rowRange(3, 4);
cout << "mchunk5 = Martrix55.rowRange(3, 4)" << endl << "mchunk5 = " << endl << mchunk5 << endl << endl;
Mat mchunk6 = Martrix55.rowRange(3, 3);
cout << "mchunk6 = Martrix55.rowRange(3, 3)" << endl << "mchunk6 = " << endl << mchunk6 << endl << endl;
system("pause");
return 0;
}
colRange()一个道理
这么例子能讲清楚吗?