OpenCV中利用cvConvertScale()将图像的数据类型由u8转化为64f...

来源:互联网 发布:php isset 属性 编辑:程序博客网 时间:2024/05/21 09:08

OpenCV中利用cvConvertScale()将图像的数据类型由u8转化为64f 

实例代码为:cvConvertScale(src, dst);  


怎么转换的?看下面的这段指自官方文档中的话你就知道了,特别是红色部分的话哈!

void cvConvertScale(const CvArr* src, CvArr* dst, double scale=1, double shift=0)

#define cvCvtScale cvConvertScale
#define cvScale cvConvertScale
#define cvConvert(src, dst ) cvConvertScale((src), (dst), 1, 0 )

Parameters
src – Source array
dst – Destination array
scale – Scale factor
shift – Value added to the scaled source array elements
The function has several different purposes, and thus has several different names. It copies one array to another with optional scaling, which is performed first,and/or optional type conversion, performed after:

dst(I) = scale*src(I) + shift

注意:optional 是可选的意思!具体来说,如果你源的数据类型是8F,那么只有当你用cvCreateImage()创建的图像是64F时,它才转换,即“cvCreateImage(cvGetSize(pSrcImage), IPL_DEPTH_64F,1);”时,才转换!

而如果是cvCreateImage(cvGetSize(pSrcImage), IPL_DEPTH_8U,1);它是不会转换的!我亲自试验过的哦!

All the channels of multi-channel arrays are processed independently.
The type of conversion is done with rounding and saturation, that is if the result of scaling + conversion can not be represented exactly by a value of the destination array element type, it is set to the nearest representable value on the real axis.

----------------------------------------------
欢迎大家加入图像识别技术交流群:271891601,另外,特别欢迎成都从事图像识别工作的朋友交流,我的QQ号2487872782

0 0
原创粉丝点击