tags:

views:

8

answers:

1

OpenCV users know that cvRemap is used for doing geometric transformations. The mapx and mapy arguments are the data structures which give the mapping information in the destination image. Can i create two integer arrays holding random values from 1 to 1024 or from 1 to 768 if i deal with images (1024 X 768) And then make mapx and mapy assigned with these values? And then use them in cvRemap()? Will it do the job or the only way to use mapx and mapy is get its value assigned by using the function cvUndistortMap()? I want to know because I want to warp the images. Just in case to tell you that I have already checked out Learning OpenCV book too.

A: 

I use cvRemap to apply distortion correction. The map_x part is in image resolution and stores for each pixel the x-offset to be applied, while map_y part is the same for the y-offset.

in case of undistortion

# create map_x/map_y
self.map_x = cvCreateImage(cvGetSize(self.image), IPL_DEPTH_32F, 1)
self.map_y = cvCreateImage(cvGetSize(self.image), IPL_DEPTH_32F, 1)
# I know the camera intrisic already so create a distortion map out
# of it for each image pixel
# this defined where each pixel has to go so the image is no longer
# distorded
cvInitUndistortMap(self.intrinsic, self.distortion, self.map_x, self.map_y)
# later in the code:
# "image_raw" is the distorted image, i want to store the undistorted into
# "self.image"
cvRemap(image_raw, self.image, self.map_x, self.map_y)

Therefore: map_x/map_y are floating point values and in image resolution, like two images in 1024x768. What happens in cvRemap is basicly something like

orig_pixel = input_image[x,y]
new_x = map_x[x,y]
new_y = map_y[x,y]
output_image[new_x,new_y] = orig_pixel

What kind of geometric transformations do you want to do with this?

zerm