在opencv中使用Rect获取范围矩阵:
//Rect类使用
Mat matrix = (Mat_<int>(5,5)<<1,2,3,4,5,
6,7,8,9,10,
11,12,13,14,15,
16,17,18,19,20,
21,22,23,24,25);
cout << matrix << endl;
Mat rx1 = matrix(Rect(Point(2, 1), Point(3, 2)));
cout << rx1 << endl;
Mat rx2 = matrix(Rect(2,1,2,2));
cout << rx2 << endl;
Mat rx3 = matrix(Rect(Point(2, 1), Size(2, 2)));
cout << rx3 << endl;
//矩阵范围元素克隆
Mat rx4 = matrix(Rect(Point(2, 1), Size(2, 2))).clone();
cout << rx4 << endl;
//矩阵范围元素克隆
Mat rx5;
matrix(Rect(Point(2, 1), Size(2, 2))).copyTo(rx5);
cout << rx5 <<