番外篇-為何是BGR不是RGB¶
概要¶
本節主要講解的是,為什么要使用BGR格式的數據結構來存放圖片
keywords BGR RGB 圖像數據結構
為什么使用BGR的數據結構?¶
我們當下普遍使用的是RGB
格式, 但是為什么cv2
返回的數據結構是BGR
格式的呢?
這個問題, 跟之前阿凱提到的cv2
的問題一樣, 同樣困擾了我.
在這篇文章中, 阿凱獲得了答案, 早前windows
下, 不管是攝像頭制造者 ,還是軟件開發者, 當時流行的都是BGR
格式的數據結構. 后面RBG
格式才逐漸流行, 所以這個是opencv
在發展過程中的歷史遺留問題.
Learn OpenCV - Why does OpenCV use BGR color format ?
The reason the early developers at OpenCV chose BGR color format is that back then BGR color format was popular among camera manufacturers and software providers. E.g. in Windows, when specifying color value using COLORREF they use the BGR format 0x00bbggrr.
BGR was a choice made for historical reasons and now we have to live with it. In other words, BGR is the horse’s ass in OpenCV.