Ask Your Question
1

Does imwirte function write an image in RGB order?

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

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
1

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

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

Stats

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

Seen: 80 times

Last updated: May 18