Channel order in OpenCV

Sometimes, you may need to access the memory of a cv::Mat or an IplImage directly. If the image contains M channels, then it becomes important to know how the pixels of these M channels are stored in the image memory. According to OpenCV documentation here:

  • The M bytes of every pixel are stored together.
  • For 3 channel image, the RGB channels are stored in BGR order. There is no particular reason for this, OpenCV just happens to store it in this order. It may be due to influence from Windows, where most internal APIs seem to deal with this channel order.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s