views:

49

answers:

1

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

+1  A: 

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);
Jacob
@Jacob:thanks for help...so CV_32FC3 works for rgb color image?..then its 1X27 vector?
ajith
Check out the example in the link I sent. There, they convert a 320x240x3 image into a 960x240x1 image.
Jacob