Difference between RGB and BGR

RGB stands for Red Green Blue. Most often, an RGB color is stored in a structure or unsigned integer with Blue occupying the least significant “area” (a byte in 32-bit and 24-bit formats), Green the second least, and Red the third least.

BGR is the same, except the order of areas is reversed. Red occupies the least significant area, Green the second (still), and Blue the third.

On some platforms (e.g. the Gamegear) a BGR model is used. However, for most, like your computer, RGB is used [citation-needed] (though BGR is supported by many graphic API’s for compatability). OpenCV supports BGR model.

I think because the standard bitmap has the following properties.

  • Bitmaps are saved row-based.
  • When the height is positive, it is a bottom-up bitmap, that is, the last line comes first in memory.
  • A row must be aligned on a 4-byte boundary.
  • Color channel order is BGR (unless specified otherwise by BI_BITFIELDS masks).

Note that the order of the channels is inverse: BGR instead of RGB. Because in many cases the memory is large enough to store the rows in a successive fashion the rows may follow one after another, creating a single long row. Because everything is in a single place following one after another this may help to speed up the scanning process. We can use the isContinuous() function to ask the matrix if this is the case. Continue on to the next section to find an example.

Resources:

http://stackoverflow.com/questions/367449/bgr-color-space

http://stackoverflow.com/questions/14556545/why-opencv-using-bgr-colour-space-instead-of-rgb

Advertisements

Published by

kaurdavinder

I am the one who discover myself daily through reading, writing, interacting with people and expressing my thoughts to inspire them if I would be able to bring a little change to the society through my work. I write blogs, participate in various social activities and want to be a Professional Speaker. Currently, I am pursuing my post graduation in Computer Applications from Guru Nanak Dev Engineering College, Ludhiana and I’m very much active in many technical & social communities.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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