opencv深入学习(2)--Scalar类型
2012-08-17 16:50
190 查看
CvScalar定义可存放1—4个数值的数值,其结构体如下:
typedef struct CvScalar
{
double val[4];
}CvScalar;
例如:CvScalar s;
如果使用的图像是1通道的,则s.val[0]中存储数据
如果使用的图像是3通道的,则s.val[0],s.val[1],s.val[2]中存储数据
cvGet2D 获得某个点的值, index0=height 行值, index1=width 列值。
CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 );
cvSet2D 给某个点赋值。
CVAPI(void) cvSet2D( CvArr* arr, int index0, int index1, CvScalar value );
Scalar
• Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel values.
• In this tutorial, we will use it extensively to represent RGB color values (3 parameters). It is not necessary to
define the last argument if it is not going to be used.
• Let’s see an example, if we are asked for a color argument and we give:
Scalar( a, b, c )
We would be defining a RGB color such as: Red = c, Green = b and Blue = a
template<typename _Tp> class CV_EXPORTS Scalar_ : public Vec<_Tp, 4>
{
public:
//! various constructors
Scalar_();
Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0);
Scalar_(const CvScalar& s);
Scalar_(_Tp v0);
//! returns a scalar with all elements set to v0
static Scalar_<_Tp> all(_Tp v0);
//! conversion to the old-style CvScalar
operator CvScalar() const;
//! conversion to another data type
template<typename T2> operator Scalar_<T2>() const;
//! per-element product
Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const;
// returns (v0, -v1, -v2, -v3)
Scalar_<_Tp> conj() const;
// returns true iff v1 == v2 == v3 == 0
bool isReal() const;
};
typedef Scalar_<double> Scalar;
typedef struct CvScalar
{
double val[4];
}CvScalar;
例如:CvScalar s;
如果使用的图像是1通道的,则s.val[0]中存储数据
如果使用的图像是3通道的,则s.val[0],s.val[1],s.val[2]中存储数据
cvGet2D 获得某个点的值, index0=height 行值, index1=width 列值。
CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 );
cvSet2D 给某个点赋值。
CVAPI(void) cvSet2D( CvArr* arr, int index0, int index1, CvScalar value );
Scalar
• Represents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel values.
• In this tutorial, we will use it extensively to represent RGB color values (3 parameters). It is not necessary to
define the last argument if it is not going to be used.
• Let’s see an example, if we are asked for a color argument and we give:
Scalar( a, b, c )
We would be defining a RGB color such as: Red = c, Green = b and Blue = a
template<typename _Tp> class CV_EXPORTS Scalar_ : public Vec<_Tp, 4>
{
public:
//! various constructors
Scalar_();
Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0);
Scalar_(const CvScalar& s);
Scalar_(_Tp v0);
//! returns a scalar with all elements set to v0
static Scalar_<_Tp> all(_Tp v0);
//! conversion to the old-style CvScalar
operator CvScalar() const;
//! conversion to another data type
template<typename T2> operator Scalar_<T2>() const;
//! per-element product
Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const;
// returns (v0, -v1, -v2, -v3)
Scalar_<_Tp> conj() const;
// returns true iff v1 == v2 == v3 == 0
bool isReal() const;
};
typedef Scalar_<double> Scalar;
相关文章推荐
- OpenCV学习笔记(3)——Scalar数据类型理解
- Struts2.0深入学习 Strust2与Servlet API,Action多方法调用,result标签的type的类型
- opencv学习-2-0初探-基本类型数据
- 【OpenCV学习笔记】【类型转换】一(IplImage和cv::Mat的类型相互转换)
- OpenCV 深入学习:IplImage 结构
- OpenCV系统学习:一、OpenCV结构、基本数据类型
- 重新学习2.0以上OPENCV(基于MAT类型)3
- 【学习OpenCV】—— 深入了解 cv::Mat
- opencv学习-2-0初探-基本类型数据
- OpenCV 学习笔记---基本数据类型
- 玩转人工智能(7)计算机视觉OpenCV库持续深入学习总结
- opencv深入学习(1)--Mat主要成员变量
- Swift 基础学习(可选类型深入探讨)
- opencv深入学习(5)—ROI区域
- opencv深入学习(1)--Mat主要成员变量
- OpenCV深入学习(4)--Mat元素的获取方法
- opencv学习-2-0初探-基本类型数据
- OpenCV学习笔记(十一)——谈谈像素的类型和对Templates的限制使用
- flume-ng学习之spooling directory类型source配置深入及解析
- 【opencv学习笔记三】opencv3.4.0数据类型解释