Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imwrite() can only save float images in ".exr" or ".hdr" format, and that only, if you built in suppport for that (WITH_OPENEXR).

alternatively, you can use the FileStorage, to save your img to yml (text):

FileStorage fs("my.yml", 1); fs << "some_name" << mat;
fs.release();

imwrite() can only save float images in ".exr" or ".hdr" format, and that only, if you built in suppport for that (WITH_OPENEXR).

alternatively, you can use the FileStorage, to save your img to yml (text):

 FileStorage fs("my.yml", 1);
fs << "some_name" << mat; 
image; fs.release();

fs.release();

imwrite() can only save float images in ".exr" or ".hdr" format, and that only, if you built in suppport for that (WITH_OPENEXR).

if you want to save it as png or jpg, you will need to convert it to uchar first:

Mat floatImg = ...
Mat ucharImg;
floatImg.convertTo(ucharImg, CV_8U, 255.0);
imwrite("my.png", ucharImg);

alternatively, you can use the FileStorage, to save your img to yml (text):

 FileStorage fs("my.yml", 1);
 fs << "some_name" << image;  
 fs.release();