Does the second channel of a C2
image represent the alpha channel or do they just fill the gap between C1
-C3,C4
?

- 45
- 5
1 Answers
You are mistaking colorspaces with channels. For example you have a greyscale colorspace, which is represented with 1 channel. Then you have BGR with 3 channels, and BGRA with 4. Here the 4th channel is the Alpha value. OpenCV supports several types of colorspaces.
OpenCV is opened to your needs, in some cases you have a mat with 2 values per pixel, for example Dense Optical Flow results, which have a vector of movement of each pixel (x,y vector). You may even create a greyscale image with alpha value for whatever reason or algorithm you have... in this case it will be a CV_8UC2
. However this is not a standard colorspace in OpenCV, and a lot of the algorithms have hard constraints on the color space so they may not work with this Mat type.
A cv::Mat can have more than 4 channels even (up to 512 the last time I checked, for more info check the constant CV_CN_MAX)
, but beware that this may not work with all of OpenCV functions and it will more like a container to your custom algorithms.

- 11,070
- 4
- 41
- 57
-
@kobermann if you find it useful you should accept the answer and possibly upvote it :) – api55 Dec 22 '17 at 09:18
-
I was not able to upvote your answer last time, but now I am. And thank you for the answer. I was working on my bachelor thesis and this saved me some time searching. – kobermann Feb 27 '20 at 09:52