Convert IplImage to 1D Vector in OpenCV

I want to convert mXn IplImage to a vector (m * n) x 1 1D. Can this be done with any function in OpenCV?

Any help is greatly appreciated.

+3
source share
1 answer

cvReshape

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

Changes the shape of the matrix / image without copying data.

And the following example converts 3x3 matrices to one 1x9 vector:

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

Source: https://habr.com/ru/post/1750651/


All Articles