Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Undistort single channel images

How can one rectify single channel images?

It seems cvInitUndistortRectifyMap wants mapx and mapy only in CV_16SC2 or it's 32F format. Further one, when I want to use cvremap:

mapx = cvCreateMat( 640, 480,CV_16SC2);
mapy = cvCreateMat( 640, 480, CV_16UC1);
cvInitUndistortRectifyMap(
    &intrinsicM,
    &distortionM,
    NULL,
    &newintrinsicM,
    mapx,
    mapy
);   
IplImage* im = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U, 1);
IplImage* rim = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U, 1);
im->imageData = (char*) data->fisheye_image;

cvRemap(im, rim,
         mapx, mapy,
        CV_INTER_LINEAR,cvScalarAll(0));

cvRemap complains saying that rim.size() and mapx.size() should be the same. However, rim is a single channel 8bit image, and mapx cannot be the same size.

How does one undistorts single channel images?

Undistort single channel images

How can one rectify single channel images?

It seems cvInitUndistortRectifyMap wants mapx and mapy only in CV_16SC2 or it's 32F format. Further one, when I want to use cvremap:

mapx = cvCreateMat( 640, 480,CV_16SC2);
mapy = cvCreateMat( 640, 480, CV_16UC1);
cvInitUndistortRectifyMap(
    &intrinsicM,
    &distortionM,
    NULL,
    &newintrinsicM,
    mapx,
    mapy
);   
IplImage* im = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U, 1);
IplImage* rim = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U, 1);
im->imageData = (char*) data->fisheye_image;

cvRemap(im, rim,
         mapx, mapy,
        CV_INTER_LINEAR,cvScalarAll(0));

When running the above, cvRemap complains saying that rim.size() and mapx.size() should be the same. same (which is stated in the doc. as well). However, rim is a single channel 8bit image, and mapx cannot be the same size.

Surely, there should be a way. How does one undistorts single channel images?