开发者

Converting IplImage into 1D vector in OpenCV

I want to convert a mXn IplImage into a (m*n) x 1 1D vector. Can this be开发者_开发技巧 done with any function in OpenCV?

Any help is greatly appreciated.


cvReshape

CvMat* cvReshape(const CvArr* arr, CvMat* header, int newCn, 
int newRows=0) 

Changes shape of matrix/image without copying data.

And the next example converts a 3x3 matrix to a single 1x9 vector:

CvMat* mat = cvCreateMat(3, 3, CV_32F);
CvMat row_header, *row;
row = cvReshape(mat, &row_header, 0, 1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜