1 | initial version |
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; //for CV_8UC1
FILE *out;
out=open("ouput.txt","w");
printf("%d %d ",pic.cols,pic.rows);
unsigned char *ptr_data=pic.data;
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++);
close(out);
I haven't compile that code, but the idea is clear.
2 | No.2 Revision |
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; //for CV_8UC1
pic;
FILE *out;
out=open("ouput.txt","w");
printf("%d %d ",pic.cols,pic.rows);
unsigned char *ptr_data=pic.data;
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++);
close(out);
I haven't compile that code, but the idea is clear.