OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 4392|回复: 5

如何实现整型图象到读点图象的转换

[复制链接]
发表于 2008-11-27 11:26:22 | 显示全部楼层 |阅读模式
打开一幅图象时,如何知道这幅图象是浮点型还是整型?能将这些类型进行转换吗?如何实现?  请各位牛人指导。。。。。
回复

使用道具 举报

发表于 2008-11-28 15:56:44 | 显示全部楼层

如何实现整型图象到读点图象的转换

LoadImage后看看图像的深度不就知道啦。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-12-16 22:22:00 | 显示全部楼层

如何实现整型图象到读点图象的转换

谢谢,知道了。。。。
回复 支持 反对

使用道具 举报

发表于 2008-12-27 09:46:54 | 显示全部楼层

如何实现整型图象到读点图象的转换

但怎么转换呢?是不是写个for循环逐个地将在整型像素矩阵中的值赋予浮点型的像素矩阵?还是另外有其它的转换函数?
回复 支持 反对

使用道具 举报

发表于 2008-12-27 17:08:56 | 显示全部楼层

如何实现整型图象到读点图象的转换

ConvertScale
Converts one array to another with optional linear transformation
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 )
src
Source array.
dst
Destination array.
scale
Scale factor.
shift
Value added to the scaled source array elements.


In case of scale=1, shift=0 no prescaling is done. This is a specially optimized case and it has the appropriate cvConvert synonym. If source and destination array types have equal types, this is also a special case that can be used to scale and shift a matrix or an image and that fits to cvScale synonym.


这是OpenCV的documentation 当scale = 1, shift = 0时, 等效于转换


待转换的类型由其头的类型决定

举例
IplImage* img = cvLoadImage(filename, CV_LOAD_IMAGE_ANYCOLOR);
IplImage* floatImage = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_32F, 3);
cvConvertScale(img, floatImage);
回复 支持 反对

使用道具 举报

发表于 2008-12-28 17:46:37 | 显示全部楼层

如何实现整型图象到读点图象的转换

学习了,谢谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-5-2 21:48 , Processed in 0.008393 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表