OpenCV need to convert IPL_DEPTH_32S to IPL_DEPTH_32F


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?

Best Solution

I don't think opencv has such a function.

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.