I am doing image rectification with opencv but a want to use the maps (mapx and mapy) that the c function cvInitUndistortRectifyMap returns to do the mapping myself (which is usually done by cvremap). In this process i find it odd that opencv only returns maps in the size of the orginal image
This means that in regions where the original image maps to outside its size the rectified image is just croped because the mappings are only of the size of the image?! Can you get a full mapping so you get the whole rectified image instead of just the part of it that is within the original image (size)?
More than a matter of image size, the cause of this is that by default, cvInitUndistortRectifyMap generates a map that points only to valid pixels in the source image. What you want is to get all the pixels.
For this you can use the newCameraMatrix parameter of cvInitUndistortRectifyMap. The value of newCameraMatrix is obtained by first calling cvGetOptimalNewCameraMatrix (See this link) and setting the alpha parameter. As explained in the link:
If you want to, you can vary the desired size of the rectified image with the newImageSize parameter of cvGetOptimalNewCameraMatrix but this will not change what pixels you get in the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With