Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Channel order in OpenCV

Tags:

c++

opencv

I have been reading in a few forums that OpenCV has the BGR channel order by default.

It is also possible that a cv::Mat may have RGB channel order.

A gray conversion would specify CV_BGR2GRAY or CV_RGB2GRAY as a parameter.

1) Are there any other options, than RGB and BGR ?

2) Is there any way to find out - through code - what the order of channels is ?

Thank you.

like image 905
Thalia Avatar asked May 20 '13 20:05

Thalia


1 Answers

Opencv always (AFAIK) uses BGR channel order, there are a few functions in the GPU module that use BGRA since opengl contexts work better with 32bit pixels.

BGR2Gray and RGB2Gray both call the same function.

The easiest way to check is to create an image in paint etc which has known R,G,B values and then examine the cv::Mat memory in the debugger

like image 76
Martin Beckett Avatar answered Sep 28 '22 18:09

Martin Beckett