OpenCV需要将IPL_DEPTH_32S转换为IPL_DEPTH_32F [英] OpenCV need to convert IPL_DEPTH_32S to IPL_DEPTH_32F

查看:78
本文介绍了OpenCV需要将IPL_DEPTH_32S转换为IPL_DEPTH_32F的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个IPL_DEPTH_32S图像(这意味着我使用32位整数表示像素),并且需要将其转换为IPL_DEPTH_32F,以便可以应用模板匹配.有谁知道将整数转换为浮点数的公式,或者任何可以执行此操作的OpenCV内置函数?

I have a IPL_DEPTH_32S image (meaning I use 32bit integer to represent pixels) and I need to convert it to IPL_DEPTH_32F, so that I can apply template matching. Does anyone know the formula to convert the integers to floats, or of any functions built in to OpenCV that can do this?

推荐答案

我不认为opencv具有这样的功能.

I don't think opencv has such a function.

最简单的方法是创建一个与IPL_DEPTH_32S图像大小完全相同的新IPL_DEPTH_32F图像.然后遍历两个图像中的所有像素,并针对每个像素副本进行循环,然后将整数像素转换为浮点像素.

The easiest way to do this will be to create a new IPL_DEPTH_32F image with exactly the same size as your IPL_DEPTH_32S image. Then loop over all pixels in both images and for each pixel copy and cast the integer pixel to the float pixel.

这篇关于OpenCV需要将IPL_DEPTH_32S转换为IPL_DEPTH_32F的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆