Ask Your Question
0

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

asked Apr 11 '16

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?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Apr 11 '16

berak gravatar image

updated Apr 11 '16

  • 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();
Preview: (hide)

Comments

I went with the second option. Thank you!

nyd gravatar imagenyd (Apr 11 '16)edit

Question Tools

1 follower

Stats

Asked: Apr 11 '16

Seen: 1,341 times

Last updated: Apr 11 '16