Ask Your Question

Covert Mat to Bitmap in c++

asked 2018-03-08 03:38:51 -0500

updated 2020-09-22 08:29:06 -0500

Is there a function or anything else in OpenCV c++ which converts a Mat to a Bitmap?

edit retag flag offensive close merge delete


what kind of bitmap are you talking about ? (context ?)

berak gravatar imageberak ( 2018-03-08 03:43:37 -0500 )edit

I'm in need of a binary Image. For better understanding I would like to see the thresholded picture displayed in Avihex, but to view the picture in avihex I need the Windows .bmp format. Is there any way in OpenCV c++ to safe a mat to a .bmp file? P.S. I'm a bloody rookie in c++ and OpenCV

yellowbanana15 gravatar imageyellowbanana15 ( 2018-03-08 04:03:28 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-03-08 04:08:21 -0500

berak gravatar image

sure, you can just save your image as a .bmp, using a simple:

Mat img = ...
imwrite("my.bmp", img);

please also bookmark the tutorials ;)

edit flag offensive delete link more


Thank you very much!

yellowbanana15 gravatar imageyellowbanana15 ( 2018-03-09 00:38:46 -0500 )edit

@berak i am not sure deleting this kind of posts

sturkmen gravatar imagesturkmen ( 2020-09-22 08:30:52 -0500 )edit

i am sorry for increasing number of your answers ( converted from comments) and karma :)

sturkmen gravatar imagesturkmen ( 2020-09-22 08:32:50 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-03-08 03:38:51 -0500

Seen: 1,494 times

Last updated: Mar 08 '18