I want to compare matrices created from OpenCV with the ones in Matlab. If the matrices are uint8, Saving them as pgm images would do the trick. But my matrices are CV_64FC1 (double) that can't be saved as images. Is there any easy way to save my double matrix for reading in Matlab?
Asked
Active
Viewed 2,951 times
4
-
1easier than file output you mean? – none Oct 02 '12 at 17:18
-
@gokcehan I don't think CV_64FC1 can be saved. Am I right? – Tae-Sung Shin Oct 02 '12 at 17:20
-
i don't think he means as images. Output the raw data to file – im so confused Oct 02 '12 at 17:23
-
well, it has been a long time since I touched opencv but can't you just print the values and save them to a text file? that's what I meant. – none Oct 02 '12 at 17:23
-
@gokcehan That's tough as they are in double precision. – Tae-Sung Shin Oct 02 '12 at 17:26
2 Answers
7
Try this one from OpenCV samples.
Mat r
std::stringstream ss;
ss << format(r,"csv") << endl << endl;
myFile << ss.str();
// or even this
myFile << format(r,"csv") << endl << endl;

Sam
- 19,708
- 4
- 59
- 82
-
Hey, I am applying your way, but I am getting strange values in my text file, my matrices are CV_64F: 51.0225219726563219.4757385253906-722.7874145507813-375.035 – farahm May 14 '14 at 13:46
0
Just write the intensity of each pixel into a file and read it with MATLAB using importdata
.

Jacob
- 34,255
- 14
- 110
- 165