简体   繁体   English

OpenCV C2类型的图像?

[英]OpenCV C2 types of images?

C2图像的第二个通道代表Alpha通道还是仅填充C1 - C3,C4之间的间隙?

You are mistaking colorspaces with channels. 您在使用通道时弄错了色彩空间。 For example you have a greyscale colorspace, which is represented with 1 channel. 例如,您有一个灰度色空间,用1个通道表示。 Then you have BGR with 3 channels, and BGRA with 4. Here the 4th channel is the Alpha value. 然后,您拥有3个通道的BGR,以及4个的BGRA。这里的第4个通道是Alpha值。 OpenCV supports several types of colorspaces. OpenCV支持几种类型的色彩空间。

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). OpenCV是根据您的需要打开的,在某些情况下,您有一个每个像素具有2个值的垫,例如“密集光流”结果,该结果具有每个像素的运动矢量(x,y矢量)。 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 . 您甚至可以出于任何原因或算法而使用alpha值创建灰度图像...在这种情况下,它将是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. 但是,这不是OpenCV中的标准色彩空间,并且许多算法对色彩空间都有严格的约束,因此它们可能不适用于此Mat类型。

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. 一个cv :: Mat甚至可以有4个以上的通道(我上次检查时最多可以有512个通道,有关更多信息,请检查常量CV_CN_MAX) ,但是请注意,这可能不适用于所有OpenCV函数,它将更像一个容器您的自定义算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM