Ask Your Question

Does imwirte function write an image in RGB order?

asked 2017-05-18 03:50:24 -0500

ririgo gravatar image

Hi, I'm studying openCV and I have a simple question. I read a RGB image and I notice that openCV store it as a Mat in BGR oder. I wanna know whether the image file is in RGB order or BGR order, if I save the mat as a png file using imwrite.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-05-18 04:06:32 -0500

berak gravatar image

yea, the whole thing is terribly confusing, but:

  • the image on disk (as a png or jpg) is in RGB order
  • the image in memory (as a cv::Mat) is in BGR order.

so, imread() will internally convert from rgb to bgr, and imwrite() will do the opposite, all under the hood.

just don't worry too much about it ;)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-05-18 03:50:24 -0500

Seen: 32 times

Last updated: May 18