Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 328
Dark Knight Avatar asked Dec 03 '25 01:12

Dark Knight


1 Answers

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);
like image 151
Jacob Avatar answered Dec 05 '25 16:12

Jacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!