📄 4-7.cpp
字号:
// 程序4-7获取数组子集函数的使用
//
/*
#include <highgui.h>
#include <cv.h>
#include <iostream.h>
#include <iomanip.h>
void main()
{
int i=0;
int j=0;
CvRect mat_rect=cvRect( 1, 1, 3, 3 ); //指定取得数组子集的范围
CvMat* mat=cvCreateMat(6,6,CV_64FC1); //源数组
CvMat* submat=cvCreateMat(3,3,CV_64FC1); //按mat_rect指定取得的数组子集
CvMat* mat_rows=cvCreateMat(2,6,CV_64FC1); //按一定跨度内的行取得的数组子集
for(i=0; i<6; i++)
{
for(j=0; j<6; j++)
{
CV_MAT_ELEM( *mat, double, i, j )=i*6+j;
}
}
for(i=0; i<6; i++)
{
for(j=0; j<6; j++)
{
cout<<setw(3)<<CV_MAT_ELEM( *mat, double, i, j );
}
cout<<endl;
} cout<<endl;
//根据mat_rect指定的范围取得数组子集
cvGetSubRect( mat, submat, mat_rect );
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
cout<<setw(3)<<CV_MAT_ELEM( *submat, double, i, j );
}
cout<<endl;
} cout<<endl;
//---一定跨度内的行取数组子集(这里为第一行和第二行注意end_row=3(因为不包括此行))------
cvGetRows( mat, mat_rows, 1, 3, 1 );
for(i=0; i<2; i++)
{
for(j=0; j<6; j++)
{
cout<<setw(3)<<CV_MAT_ELEM( *mat_rows, double, i, j );
}
cout<<endl;
}
cvReleaseMat(&mat);
cvReleaseMat(&submat);
}
//*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -