Ask Your Question
0

How to write and then read a CV_64FC1 and preserve precision?

asked 2016-04-11 05:44:18 -0600

nyd gravatar image

imread and imwrite apparently don't work with floats, so I should convertto integers, but then, there is no 64bit integer that I could recast to 64bit float. So what do I do?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2016-04-11 05:52:59 -0600

berak gravatar image

updated 2016-04-11 05:54:14 -0600

  • if your opencv libs were compiled with openexr support (check cv::getBuildInformation()), you can save the image as .exr or .hdr . this is the only way with imread/imwrite.
  • you can save it as a text file, using FileStorage:


 Mat floatImg = ...
 FileStorage fs("my.yml", FileStorage::WRITE);
 fs << "myimg" << floatImg;
 fs.release();


 Mat floatImg;
 FileStorage fs("my.yml", FileStorage::READ);
 fs["myimg"] >> floatImg;
 fs.release();
edit flag offensive delete link more

Comments

I went with the second option. Thank you!

nyd gravatar imagenyd ( 2016-04-11 08:56:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-11 05:44:18 -0600

Seen: 1,303 times

Last updated: Apr 11 '16