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.