opencv、Vec2b、Vec3b有不同的类型。Vec4i等等,还有Scalar类型。据我所知,Vec3b和Scalar都是存储三个数字的类型。所以,如果我想访问一个像素(以RGB格式),我只是在编写image.at <Vec3b> (x,y)=Vec3b ( number, number, number),同样适用于Scalar,但是它们的区别是什么,甚至有什么不同呢?
I am asking this since I am having some weird experiences with using Vec3b and Scalar, when I am suing Scalar ( I am trying to convert some pixels into grayscale but leave the image in RGB format ) by doing this `image.at<Scalar>(x,y)=Scalar( gray_image.at<uchar>(x,y), gray_image.at<uchar>(x,y), gray_image.at<uchar>(x,y));` ( I have the same image in grayscale called gray\_image), but this appears to give some weird results, on the other hand when I am using Vec3b instead of Scalar I am getting normal results. Why is that happening?发布于 2015-07-02 12:21:21
根据structures.html的说法,Scalar_是
从
Vec派生的4元素向量的模板类。
哪一个
从
Vec<_Tp, 4>派生而来的Scalar_和Scalar可以作为典型的四元素向量使用.此外,可以将它们转换为/从CvScalar转换。Scalar类型在OpenCV中被广泛用于传递像素值。
其中,作为一个Vec:
用于短数值向量的模板类,这是
Matx的一个部分情况:
和
Vec类通常用于描述多通道阵列的像素类型.详情请参见Mat。
所以它们是不一样的。
https://stackoverflow.com/questions/31184282
复制相似问题