4

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?

Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240

2 Answers2

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