Ask Your Question

Get every element from a mat without any symbols

asked 2014-01-13 03:59:25 -0500


i would like to get every elemt from a mat without any bracktets ( [,] or ,]

So I create a txt file and write there every element of my mat.

It looks like: [ 91, 28, 129, ...] But i want, that it looks like this example: 91 28 129

How I can do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-01-13 04:08:04 -0500

updated 2014-01-13 04:08:48 -0500

Just write the values of the pixels directly into the TXT, but you will need to save the size of the mat too (for example first two values)

Mat pic;
FILE *out;
printf("%d %d ",pic.cols,pic.rows);
unsigned char *;
for(int i=0;i<pic.cols*pic.rows;i++)  //for CV_8UC13 the condition is i<pic.cols*pic.rows*3
      printf("%d ",(int)*(ptr_data++); 

I haven't compile that code, but the idea is clear.

edit flag offensive delete link more

Question Tools


Asked: 2014-01-13 03:59:25 -0500

Seen: 129 times

Last updated: Jan 13 '14